简体   繁体   English

如何更改 Korge NinePatch 的宽度和高度?

[英]How to change Korge NinePatch width and height?

I am developing a game using Korge game engine.我正在使用 Korge 游戏引擎开发游戏。

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.我尝试更改附加到 FixedSizeContainer 的 NinePatch 的宽度,但是在运行此代码时,NinePatch 图像的侧面会变形。

     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更新-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.根据 Korge文档,我使用的是 NinePatch 的扩展版本,它使用了 KorIM 的 NinePatchBitmap32,与 IntelliJ 9 补丁 bitmap 兼容。

When I switched to normal NinePatch from NinePatchEx it is working fine.当我从NinePatchEx切换到正常的NinePatch时,它工作正常。 But I can not use 9-patch bitmap directly但是我不能直接使用9补丁bitmap

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更新 2

I found an open issue related to my problem我发现了一个与我的问题相关的未解决问题

My game is using Korge Version 1.13.9.0我的游戏使用的是 Korge 版本1.13.9.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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