Getting started: TexturePacker and LibGDX

This overview shows you how to create your first sprite sheet and include it into your LibGDX project.

These easy steps will cost you less than 5 minutes - but will greatly improve your development. Promised!

1.
Open TexturePacker, select LibGDX as framework.

TexturePacker: Select LibGDX as framework

2.
Add sprites ...

Drag & drop sprites
onto TexturePacker.


... or folders

TexturePacker adds
all sprites inside the folder
and updates the texture
when the content changes.

Add Sprites to TexturePacker

3.
Set output files
Make sure to set the output path of both files inside the assets/data directory of your project.

Set the output path for your files

4.
Set the size constraints to POT (Power of 2)

TexturePacker: Set size constraints to Power-of-2

5.
Click Publish sprite sheet
to write the sprite sheet
to your project.

TexturePacker: Click Publish sprite sheet

6.

Load sprite sheet

spriteSheet = new TextureAtlas("assets/data/spritesheet.txt");

7.
Create sprites

extract a single sprite from the sprite sheet

mailbox = spriteSheet.createSprite("mailbox")

8.
Create animations

extract animation sprites from the sprite sheet

private Array<Sprite> capguy_walk;
capguy_walk = spriteSheet.createSprites("capguy_walk")

Animate your sprites by looping through the frames of the array:

while(condition) {
    currentFrame = (currentFrame == capguy_walk.size - 1)
        ? 0
        : ++currentFrame
}

Do you want to read more?

Head over to our LibGDX tutorials section.

Do you have any feedback or questions?