Reputation: 441
I am developing a game using Korge game engine.
I tried to change the width of a NinePatch, which is attached to a FixedSizeContainer but when running this code,NinePatch image's sides getting distorted .
val scoreBg=ninePatch(resourcesVfs["gamescreen/scorebg.9.png"].readNinePatch(),
40.0,30.0){}
.position(40.0,40.0) //<-- rendering correctly
val score=text("0",font = font).centerOn(scoreBg)
val scoreUpdateFun:(score:Int)->Unit = {
val text="$it"
val len=text.length
scoreBg.width=30+len*10.0//<---- changes width but distorts sides
score.text="$it"
}
scoreUpdateFun(100)
What is the correct method to change the width/height ?
Update-1
By the Korge docs, I was using extended version of the NinePatch, that uses the KorIM’s NinePatchBitmap32, that is compatible with the IntelliJ 9-patch bitmap.
When I switched to normal NinePatch
from NinePatchEx
it is working fine.
But I can not use 9-patch bitmap directly
I changed code to
val scoreBg=ninePatch(
atlas["scorebg2.png"],40.0,30.0,
53.0/119.0, 47.0/101.0, 52.0/119.0, 47.0/101.0)
.position(40.0,40.0)
Update-2
I found an open issue related to my problem
My game is using Korge Version 1.13.9.0
Upvotes: 0
Views: 133
Reputation: 438
It is fixed already. You can check a working sample here:
9-patch image: https://github.com/korlibs/korge-samples/blob/master/ninepatch/src/commonMain/resources/image.9.png Sample updating the patch moving the mouse: https://github.com/korlibs/korge-samples/blob/master/ninepatch/src/commonMain/kotlin/main.kt
Upvotes: 1