libgdxtexturepacker

texture packer doesn't create one huge image of images


I'm following a book about libgdx and I haven't comprehend texture atlases as I would like to. As far as I understood, Texture Packer creates one huge image with all textures and atlas or pack file. But when I run it it creates atlas/pack file and than stores all the images one by one. I end up with the same number of images as I stared with, therefore I have done nothing. Why is that happening? What additional option needs to be checked, so I can create one huge file of images? I used this texture packer https://code.google.com/p/libgdx-texturepacker-gui/


Solution

  • I would not use the Texture Packer GUI as it is easier and faster to pack textures from source. If you work with eclipse, you can do the following.

    1. Make raw-assets folder inside your android/assets folder and copy your images there
    2. Make pack folder inside your android/assets folder
    3. Create a new class on the Desktop project and copy this code

      public class TextureSetup {
      
          static String input = "../android/assets/raw-assets";
          static String output = "../android/assets/pack/";
          static String atlas = "my-assets";
      
          public static void main(String[] args){
              TexturePacker.process(input, output, atlas);
          }
      }
      
    4. Run as java app

    If you use gradle and the TexturePacker class is not found, add gdx-tools to your build.gradle file.

    project(":desktop") {
        apply plugin: "java"
    
    
        dependencies {
            compile project(":core")
            compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
            compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
            compile "com.badlogicgames.gdx:gdx-tools:$gdxVersion"
        }
    }
    

    Refer to the official doc on Texture Packer for more info and options https://github.com/libgdx/libgdx/wiki/Texture-packer