Skip to main content

Texturepacker Libgdx Exclusive May 2026

assets-raw/ ui/ buttons/ backgrounds/ characters/ player/ enemy/ Every folder you point TexturePacker at becomes one "Atlas" (one .atlas file + one .png ). Step 3: Running the Packer (The LibGDX Way) Inside your LibGDX project (usually in your core module or a standalone desktop launcher), write a small one-off packing script.

SpriteBatch batch = new SpriteBatch(); TexturePacker.renderDebugImage(gameAtlas, batch, 0, 0); | Problem | Solution | | :--- | :--- | | White lines around sprites | Enable edgePadding and duplicatePadding in settings. | | "Texture too large" error | Lower maxWidth to 1024 or 512. (Or check GPU limits). | | Animation frames out of order | Name files run_01.png , run_02.png . The packer sorts alphanumerically. | | AssetManager reload crash | Don't create a new TextureAtlas for every screen. Dispose the old one first. | Final Verdict: Don't Ship Without It I’ve seen prototype LibGDX games run at 25 FPS. After packing the UI and sprites into 2 atlases, they jumped to 60 FPS instantly. texturepacker libgdx

Run this every time you change your art. Put it in a Gradle task so you never forget. Step 4: Loading the Atlas in LibGDX Once packed, you get two files: ui-atlas.atlas and ui-atlas.png . Copy these to your Android/assets folder. | | "Texture too large" error | Lower

// Instead of loading 100 textures... TextureAtlas gameAtlas = new TextureAtlas(Gdx.files.internal("ui/ui-atlas.atlas")); // Grab a single region TextureRegion buttonRegion = gameAtlas.findRegion("green_button_01"); The packer sorts alphanumerically

If you’ve been developing with LibGDX for more than a week, you’ve likely heard the mantra: “Batch your draw calls!”

// Or create an AtlasSprite for advanced animation AtlasSprite cursorSprite = new AtlasSprite(gameAtlas.findRegion("cursor")); Here’s where the magic happens. You don't need to change your code logic.