简体   繁体   中英

How to change Korge NinePatch width and height?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM