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!

Open TexturePacker, select LibGDX as framework.

TexturePacker: Select LibGDX as framework

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

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

Set the size constraints to POT (Power of 2)

TexturePacker: Set size constraints to Power-of-2

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

TexturePacker: Click Publish sprite sheet


Load sprite sheet

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

Create sprites

extract a single sprite from the sprite sheet

mailbox = spriteSheet.createSprite("mailbox")

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?

By clicking 'Submit' you agree that the data entered above is sent to and stored by CodeAndWeb GmbH for the purpose of answering your request. The data is transmitted through an encrypted internet connection and processed according to our privacy policy. You can withdraw your consent at any time with effect for the future.