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/
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.
raw-assets
folder inside your android/assets
folder and copy your images therepack
folder inside your android/assets
folderCreate 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);
}
}
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