In our example, we will use default settings, with .png texture as a output. Lets say, we have 4 sprites, open previously installed Texture Packer and drag and drop your sprites in the Sprites field (on the right) See screen below (click to enlarge)
In our example, we are using following options:
Data Format: AndEngine
Data File: select patch where output will be copied (ex. Desktop/our_texture.xml)
Texture format: we are using png.
Texture File: path where output will be copied (ex. Dekstop/our_texture.png)
Java File: path where output will be copied (ex. Desktop/OurTexture.java) this java file, simply contains ID`s of particular sprites, we will later use those ID`s to create Texture Regions in our game.
Java Package Name: put package name for generated java files (you will paste this java file in your project later on, so use proper package name)
PNG Opt Level: manipulate with it, if you want to reduce generated png file size, note that the higher this value is set, the longer process of creating texture by texture packer will take, usually few seconds, worth if you need to reduce app size.
Image Format: We used RGBA 8888 - highest quality, but also highest memory usage, you can cut memory usage by 50% by using lower quality texture (RGBA 4444) and enabling dithering to compensate quality loss - see this article for more info!
Roll over on different options, to see option description, some important notes:
In max size, better use 1024x1024, because many devices, still are not capable to support bigger textures, which leads to crashes and different issues.
In Size Constraint, use any size - it will reduce texture size, which means less memory (power of 2 texture size requirement is no longer needed in GLES2!)
Do not use trim mode, this feature is not yet supported by AndEngine.
You can use rotation, sometimes it helps to reduce texture size (means less memory)
Next final step, exporting our texture, to do it, press PUBLISH button, after few seconds, all files should be exported to the specified path. As an output, you should receive:
one texture file (in our example our_texture.png)
one data file (in our example our_texture.xml)
one java file (in our example OurTexture.java)
That`s all for first step, our texture is ready to be used in game, at the end, make sure to save texture file project file, to be able to modify it later in the future.
If you followed steps mentioned previously, and you already downloaded AndEngine Texture Packer extension and linked its source to your game project. Now we are ready to use previously created textures in your game.
Put files created by Texture Packer in the assets folder (in your app project).
What we just did? We just created and loaded new texture pack, and texture pack library (which parse and store our texture regions) By loading data file from assets, in our example this file is called our_texture.xml
Next, we just create texture regions, by using get(ID) method. You can manually specify those ID`s, but to make it easier, use auto generated java file to use variables (generated by Texture Packer, in our example OurTexture.java)
That`s all, we successfully loaded texture created by Texture Packer. This way we can easily load any ITextureRegion, if you want to load ITiledTextureRegion - follow this article.