Learn how to use tile animations - AnselmeClergeot/FisoEngine GitHub Wiki
Now that you know how to manipulate, shade your world, add entities, it may be usefull to know how to animate your map tiles. Ready?
You may be wondering why the tile images in your tileset are vertically-aligned... It's because the horizontal alignment is reserved to the animations. This is how we manage our animations in the tileset:

The 1, 2, 3 numbers represents the first, second and third frames.
Note that you can set different animations lengths for each tile type in the tileset.
First, you have to know that you need to access the animations interface by doing:
myMap.animator()//.coolStuff();Then before beggining to set tile animations up, you have to set the speed of the animations in delay between each frame in milliseconds:
myMap.animator().setSpeed(100); //For exampleNote that you can get the animations speed:
myMap.animator().getSpeed();Without going into details, the first thing to do is setting up a tile animation by informing the tile number and the length of the animation in frames. For tile number 2 that is composed of 4 frames, you will have to do:
myMap.animator().setAnimation(2, 4);With doing only this, you should see your tiles number 2 animating with 4 frames. When you only call this method, the number 2 tiles will be set to always loop. By doing this, the number 2 tiles are global animations: used for water, lava, etc. If your number 2 tile should always loop, work is done.
If number 2 tiles should only be single played at specific moments, let's go on to see what to do.
If you want to manage tile animations that have to be launch at a specific moment, you have to use single animations (for doors, etc.).
Start by setting the animation of your tile by the way seen above.
If for example tile number 7 corresponds to door animation, call:
myMap.animator().setSingleAnimKind(7);Contrary to the above behaviour, number 7 tiles will not be automatically animating but wating for.
You can do the same operation for setting a tile type to "Global" kind like that:
myMap.animator().setGlobalAnimKind(7);And this operation works as the same way as the one above.
Without doing this part, nothing will be animated in your map. In your frame loop, call :
myMap.animator().next();And now everything should animate.
When the time is come to anim one of your tile:
myMap.animator().launchAnimation(your3DCoordinates); And the tile at the specific coordinates sent should play once.
Note that if you call to animate a global tile animation (that have been set "stopped" for example), the tile should restart to loop permanently and not once.
When you want to stop an animation, you have to call:
myMap.animator().stopAnimation(your3DCoordinates);And the tile at your3DCoordinates should stop playing, global or not.
Imagine that one day you say: "oh, I want that this tile, corresponding to global animations, become a single animation tile (or vice versa). But only this one, not all the tile of the same number!"
It's possible.
For example, imagine a fire tile that is always playing. Sudenly, the player extinguishes it and could have the possibility to re-light the fire. Then this fire tile should become of single kind.
You have to operate like this:
myMap.animator().setKindOf(your3DCoordinates, yourType);yourType can be Single or Global, corresponding to your will.
If you set a door animation that opens it, it may be usefull to close this door.
To do that, you just have to play this animation backward.
To set the direction of any animated tile (Global or Single), do that:
myMap.animator().setDirectionOf(your3DCoordinates, yourDirection);Then the tile at "your3DCoordinates" should play the direction you set.
yourDirection can be Left or Right, corresponding to your will.
Note: Default direction for animations is Right.
You would like to get some informations from different parts of the animations system. Let's see how to get them.
To get the present frame number of the animation of a tile, here is how to do:
myMap.animator().getFrameAt(tileCoordinates);The status of an animation is playing/not playing so On/Off in the fe::Status enum. To get the status of the animation of a tile:
myMap.animator().getStatusAt(tileCoordinates);To get the animation kind of any tile, you have to do:
myMap.animator().getKindAt(tileCoordinates);To get the animation direction of any tile, you have to do:
myMap.animator().getDirectionAt(tileCoordinates);To get the animation length of the tiles of the same number, you have to call:
myMap.animator().getAnimLengthOfTile(tileNumber);To get the animation kind of the tiles of the same number, do:
myMap.animator().getAnimKindOfTile(tileNumber);