Hi, I have a question on how to animate sprites without using actions. I'm working on a game that has several different units. They are seen from the top and I have rendered 360 degree turns from 3D objects with a fixed light source, so that I have 32 diffrent frames of animation from which I want to choose to display the rotation of the units in the game. They don't rotate always at the same speed so a repeating animation actions does not help. I need to select the correct frame for the rotation for every unit in every frame. So I want a solution that has a good performance.
The sprites for the units are pretty small by the way. I might be able to fit everything I need for the units into one 1024x1024 pixel image.
At the moment I think about doing this way:
-rename the animation frames for all units so that they all are unique
-make a spritesheet in zwoptex format
-load it via spriteSheetWithFile
-preload every frame for every unit using spriteWithSpriteFrameName and set them all invisible
-in the process give the sprites tag numbers and link those to the data objects that hold all the propertys of the units
-in every frame for every unit set the correct sprite visible and the last one invisible, set the correct position and maybe a little rotation offset to make the rotation even smoother
Does it make sense or is this a stupid idea? I tested performance in the simulator with 10k sprites created that way from the same frame, all made invisible, and they don't seem to be heavy on performance. Switching visibility on and off for the animation seems to work, but I only tested it on 1 unit, so it's only still a concept without proof.
I read that using a TextureAtlas would greatly improve performance but the documentation on those things is confusing me. The way I use to create sprites from a spritesheet, will they use the same Atlas to get max performance?
At least the way I tried it, was way faster than loading them from a single image file each.
When keeping track of the hundreds of sprites for all the units and rotation frames, should I use pointers to the sprite objects, oder save the tags in integer variables and use getChildByTag on every unit in every frame? What's faster?
I hope my questions where clear and maybe the thread will be helpful to someone else too, because I searched and could not find a good solution on what I'm trying to do. May be we'll find one.