Lets imagine you have that files structure you use for TexturePacker2
:
images/
image1.png
image2-ninepatch.png <-- this is NinePatch
image3.png
Just change your extention of NinePatch
files from .png
(for example) to .9.png
(and add 1px border to it, if needed).
images/
...
image2-ninepatch.9.png
...
After this you could use Skin
to wrap your textures and easly extract NinePatch
and TextureRegion
from Atlas
:
TextureAtlas atlas = ... // load the Atlas
Skin skin = ... // create some root skin or use created one
skin.addRegion(atlas); // register atlas in skin
Furthermore, you could add many atlases to one skin!
Now you could do these:
Get
TextureRegion
by name:public TextureRegion getRegion(String region) { return skin.getRegion(region); }
Get
NinePatch
by name:public NinePatch getNinePatch(String region) { return skin.getPatch(region); }
Even use your images (
TextureRegion
orNinePatch
) in your UI components (like button background etc) that use this skin.
I hope it helps you!