Retrieving whole subdirectory from packed spritesheet

Talk about graphics, 3D models, nice sprite sheets, music, sound effects and anything related to the presentation of your game (not code :)).

Retrieving whole subdirectory from packed spritesheet

Postby dofudo » Sun Jun 25, 2017 5:45 pm

Hey guys, is it possible to retrieve every texture inside a specific subdirectory packed with texturepacker via assetmanager? I have many images for different animations and i don't want to create a new spritesheet for every animation in my game.
dofudo
 
Posts: 1
Joined: Sun Jun 25, 2017 5:36 pm

Re: Retrieving whole subdirectory from packed spritesheet

Postby raeleus » Mon Jun 26, 2017 9:31 pm

To use subdirectories for organization without TexturePacker outputting a set of pages for each subdirectory, see the combineSubdirectories setting.


Please read the wiki page on texture packer.
Play Forward Gunner!
Create skins visually with Skin Composer.
raeleus
 
Posts: 327
Joined: Wed Aug 07, 2013 10:57 pm

Re: Retrieving whole subdirectory from packed spritesheet

Postby XdebugX » Sat Sep 30, 2017 7:06 am

If you name each frame of the animation with and underscore and number for the frame number, you can load all of those textures from the sprite sheet into an AtlasRegion array or animation just one line of code. See the wiki section on animations: https://github.com/libgdx/libgdx/wiki/2D-Animation

TexturePacker and TextureAtlas provide a convenient way to generate animations. All the source images of an animation should be named with an underscore and frame number at the end, such as running_0.png, running_1.png, running_2.png, etc. TexturePacker will automatically use these numbers as frame numbers (so long as the packing parameter useIndexes is left true).

After the TextureAtlas is loaded, a complete array of frames can be acquired at once and passed into the Animation constructor:


To load into a texture array use:

private static Array <AtlasRegion> aa;
aa = atlas.findRegions("animation");

You can get the texture of each frame of the AtlasRegion by:

for (p=0;p<aa.size;p++) {
texture[p]= aa.get(p);
}
XdebugX
 
Posts: 47
Joined: Wed Jan 09, 2013 9:30 pm


Return to Game Art

Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest