Libgdx’s texture packer works great with packing ninepatches, but actually using the ninepatches took some figuring out. Hopefully the following information on how to use the packed ninepatches will save you some trouble.
- Once you have your ninepatch asset make sure you save it with a .9 before the extension (i.e. myImage.9.png)
- TexturePacker will detect the .9 extension when it packs the image and will remove the Ninepatch border and instead put the Ninepatch split information in the atlas file
123456789#.atlas filemyImagerotate: falsexy: 2, 471size: 222, 39split: 103, 87, 9, 10orig: 222, 39offset: 0, 0index: -1
- When you want to use the NinePatch in your code, instead of using TextureAtlas.findRegion(String region) you use:
Java12345TextureAtlas atlas;NinePatch ninepatch = atlas.createPatch("myImage");//In the draw codeninepatch.draw(getX(),getY(),getWidth(),getHeight());