I got these images and when I pack them they come in the wrong order, like the last 7 images or so go to the front and this messes it all up for me and I don't even know why.I have packed images before with no problems.
Asked
Active
Viewed 1,472 times
0
-
Why does the order matter? The order is completely arbitrary because the packer is attempting to optimize the size of the packer image. How are you retrieving the images? – Tenfour04 Jun 02 '16 at 19:12
-
Im retrieving them by this `batch2.draw(animation.getKeyFrame(elapsedTime, false), -6.3f, -5.1f, 2f, 3f);` with a timer starting – The Prophet Jun 02 '16 at 19:16
-
I mean how are you retrieving the texture regions from the atlas. – Tenfour04 Jun 02 '16 at 19:18
-
I create an `animation = new Animation(1/15f,textureAtlas.getRegions());` – The Prophet Jun 02 '16 at 19:22
-
and the textureAtlas is just `textureAtlas = new TextureAtlas("personanimation.pack");` – The Prophet Jun 02 '16 at 19:23
-
If you suffix your sequence with `_01`, `_02` etc... you can just load that into the animation and it will have a proper sequence. It will use index in the atlas. It even gets rid of duplicates in case you rendered a duplicated frame. – Madmenyo Jun 03 '16 at 23:44
1 Answers
2
TexturePacker does not store regions in a certain order unless you specify that order using indices appended to the file names. The intended way to pack and retrieve an animation is as follows:
1) Name the source images with their frame numbers appended, for example:
run1.png, run2.png, run3.png, etc.
2) Pack them with TexturePacker.
3) After loading the TextureAtlas, retrieve a set of regions by name. For example:
animation = new Animation(1/15f, textureAtlas.findRegions("run"));
The retrieved regions will be in the order of the frame numbers that were in the source file names.

Tenfour04
- 83,111
- 11
- 94
- 154
-
I got all the images excactly the way you posted: vn1.png, vn2.png... ,but when I look at my textureAtlas pack it begins like vn7,vn8,vn9,vn10,vn6,vn3,vn4,vn5 :/ – The Prophet Jun 02 '16 at 19:51
-
Have you modified the texture packer default settings? There is one called useIndices which should remain true. Or maybe I am remembering wrong and you also need an underscore before those numbers in the file names. – Tenfour04 Jun 02 '16 at 20:16
-
I can not see any use indices, or do you mean use aliases?I have tried a lot of different settings, but still nothing. I had put a link in my post where the images are that I want to pack. – The Prophet Jun 03 '16 at 13:04
-
Looks like it's spelled `useIndexes` --I was going by memory. :) The instructions for properly using TexturePacker are in the documentation: https://github.com/libgdx/libgdx/wiki/Texture-packer Which TexturePacker are you using, by the way? The reason I ask is I'm now remembering that people occasionally ask questions on here and their problems have to do with them using TexturePacker-gui, which is based on a very outdated TexturePacker. – Tenfour04 Jun 03 '16 at 14:51
-
But it does not matter in what order they are in the texture pack??? As long as the animation is good right? – Madmenyo Jun 03 '16 at 23:47