![]() ![]() There are several ways to use ninePatch, but this is the one that occurred to me right now for this case I hope, well understood, and to help you something.Įdit: I just tested the tool you use and works well. atlasUiScreenOverflow.atlas atlasUiScreenOverflow.png tBounds(100, 250, 250, 250) Īdd in stage for example: yourStage.addActor(textButton) Įg: if your button is greater than or equal to the side of ninePath, looks like this: (sorry for my English Hope you understand me well)īut if it is less than nine line for example 100 look this: TextButton = new TextButton("test", textButtonStyle) TextButtonStyle.up = new NinePatchDrawable(buttonUpNine) add in Show or created for example: buttonsAtlas = new TextureAtlas("data/ninePatch9/atlasUiScreenOverflow.atlas") īuttonUpNine = buttonsAtlas.createPatch("buttonUp") įont = new BitmapFont() //** default font, for test**//įont.setColor(0, 0, 1, 1) //** blue font **// variable Class: private TextureAtlas buttonsAtlas This tool can be found at: yourAndroid-sdk/tools/->draw9patch I use draw9patch, I do not know if it is the tool you use, do not know. I think one of the mistakes is the image line. I would really appreciate any help with this, I am completely stumped and there doesn't seem to be any up to date tutorials or documentation available. Whilst output 2 looks like it is better, it actually seems as though the 9 Patch qualities are ignored and the image has been simply stretched to fit. Method 2: TextButtonStyle buttonStyle = new TextButtonStyle() īuttonStyle.up = new NinePatchDrawable(new NinePatch(new Texture(("images/buttons/rest.9.png")))) īuttonStyle.down = new NinePatchDrawable(new NinePatch(new Texture(("images/buttons/active.9.png")))) Method 1: TextButtonStyle buttonStyle = new TextButtonStyle() īuttonStyle.up = new NinePatchDrawable(buttonAtlas.createPatch("rest")) īuttonStyle.down = new NinePatchDrawable(buttonAtlas.createPatch("active")) Skin.add("active", buttonAtlas.createPatch("active")) įinally I tried to apply this Skin to the button. Skin.add("rest", buttonAtlas.createPatch("rest")) TextureAtlas buttonAtlas = new TextureAtlas("images/buttons/buttons.pack") Next I tried to create a TextureAtlas from this pack, create a Skin, and load the images into the Skin. After running the TexturePacker things still seem to be working, because the images have "split" defined which I think suggests they have been recognised as 9 Patch files. If you’re completely new to game dev and have never developed a game before, this (even more straight-forward) tutorial by tann is also worth a look as an alternative. Below is a picture of "active.9.png":īecause I am using LibGDX and there will be many assets I wanted to use a TextureAtlas to store my button images. After you have created your very first libGDX project, we highly recommend our A Simple Game and Extending the Simple Game pages. I used this tool to create them: so I am sure they meet 9 Patch requirements. These are square images that represent the button in it's active or rest state. I have two images, "active.9.png" and "rest.9.png". ![]() I am trying to use 9 Patch images as the backgrounds to the buttons on the menu however it appears the 9 Patch qualities of the images are being ignored. I am attempting to create a simple game using LibGDX. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |