# How to play animations (GIF, SWF… )?

I have many diffrent animations made with flash.
I can make it as (1).SWF, (2).GIF or as (3).PNG (every Frame per second).
Searched in google... but coudn't find anything usefull.

1. SWF: For SWF i need Flash on the android phone... this is something new to me and because of that i woudn't prefer a solution with that.
-> I heard that Flash is not supported on Android for a long time, so this does not work.

2. GIF: If that is possible it woud be very nice. I'm thinking of something like "animation1.start();".
But i heard that android can't handle GIF.. -.-

3. PNG: I know how to animate many .png pictures with an animationdrawable but when i export the animations into a .png for every frame in the second... imagion how many pictures i have. The problem is that i can't make subdirectorys in the drawable folder. Why? I don't have a clue. :/ But realy, that woud suck.

Do anyone have any solution to that than pls feel free to tell me. :)

Edit: I didn't finde a easy solution so i will make it with animationdrawables.
If you have a solution... pls pls answer here :)

Export to PNG and use a texture packer to create one texture-atlas/spritesheet.

These texturepacker export a text file( usually a json file ). This file contains all coordinate data. If you plan on using your own implementation look at the LibGDX source code and see how its making use of texture packer files.

Edit:

Because you are rather new to gamedev, it would be way easier if you just used LibGDX. If you insist on doing your own things then:

With libgdx-texturepacker-gui: first you need to understand how json works. If i'm not mistaken in the package android.util there should be a jsonreader class. You need to parse the json file and read the coordinates you need to clip the image with when you draw it. There is an example that comes with the zip file called "test-me". It shows how to pack textures.

Open the project in that folder and hit : Pack selected. It will create some files in the output folder. It will create a png ( your sheet/atlas ) and .pack file ( your json file you can open it with notepad or any other text editor and read what created based on those images)

For animations you need to do some extra work, because you create sequences based on the region names ( that's why you just need to use something like libgdx, it's all done for you).

withtexturepacker: There are several formats it can export too, but that's up to you. Same story as above you need to parse the file and need to create a function to get the region you want.

Alternatively you don't use a texture packer and create the texture atlas yourself by placing the images uniform in a sequence like so:

[][][][][]        <---- animation 1 : 5 frames
[][][]            <---- animation 2 : 3 frames
[][][][][][][][]  <---- animation 3 : 8 frames
[][]              <---- animation 4 : 2 frames


But you will not only waste space on your atlast ( meaning it might consume more memory ), you still have to write something that disects every sequence.

• I can't find my way through the LibGDX and also don't know how to work with this texturepacker. Is there anywhere a tutorial etc. how i can start with this things? – besnep May 29 '13 at 11:55
• I've edited the answer, short story you'd still have to do some work to get it done. It doesn't have to be difficult if you simply understand the concept of how spritesheets/textureatlas are used in games. – Sidar May 29 '13 at 16:27

Alternatively to texture packing, you could simply load each frame one at a time and stream them with animation. SpriteSheets are not required, although they can (not always) save on memory.

• Year, that is the way i already knew. I will try the way Sidar said but when i don't get it to run, than i just will do the normal, old way :) – besnep May 27 '13 at 19:46