LibGDX 9修补纹理绘图问题

时间:2016-07-17 21:49:05

标签: libgdx textures nine-patch

所以我正在进行2D像素游戏,而且我在屏幕上绘制9ptach纹理时遇到了麻烦。

代码:

TextureRegion texture = TextureManager.navigationButton;
NinePatch patch = new NinePatch(texture, 1, 1, 1, 1);
NinePatchDrawable ninePatch = new NinePatchDrawable(patch);
background = new Image(ninePatch);

TextureManager.navigationButton只是atlas .9 texturregion

navigationButton = textureAtlas.findRegion("navigationmenu.9");

这是按钮的外观: enter image description here enter image description here

我尝试将九个补丁值从0改为10左右,但没有任何帮助。

或者它看起来像这样(九条补丁线) enter image description here

1 个答案:

答案 0 :(得分:0)

您应该将for(auto it:iterators(vec)) 作品委托给Skin

1, 1, 1, 1

但是如果您想使用Skin,您可能希望使用按钮的全部功能,例如ImageButton。因此,您可以在皮肤本身中定义// load the skin first Skin skin = new Skin(...); // well, you can use even empty skin skin.addRegions(textureAtlas); // get the nine-patch from it NinePatch patch = skin.getPatch("navigationmenu"); NinePatchDrawable ninePatch = new NinePatchDrawable(patch); background = new Image(ninePatch); 个变量:

navigationmenu

然后做这个魔术:

"com.badlogic.gdx.scenes.scene2d.ui.ImageButton$ImageButtonStyle":
{
    "button-navigation":
    {
        "imageUp": "navigationmenu"
    }
}