Libgdx’s TexturePacker and NinePatches

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.

  1. Once you have your ninepatch asset make sure you save it with a .9 before the extension (i.e. myImage.9.png)
  2. 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
  3. When you want to use the NinePatch in your code, instead of using TextureAtlas.findRegion(String region) you use:

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve this equation to verify you are a not a computer * Time limit is exhausted. Please reload the CAPTCHA.