Simple Animation Function
















































Simple Animation Function
This is a very simple animation function that anyone can use in their games. It's a bare-bones demo to keep everything as simple as possible. The function itself is only 14 lines and 74 tokens, and works like this:
anim(object, start frame, number of frames, speed (in frames per second), [flip])
In the demo, the object is the player, but it can be anything. Start frame is where the animation to be played begins (so in this case, moving leftright starts on frame 6, so we have anim(player,6,[..])). Number of frames is how many frames in that animation to play. We have 3, so anim(player,6,3,[..]). Speed is how fast the animation should play in frames per second (I have it set to 10 here). Lastly, flip is whether or not to flip the sprite horizontally (this parameter is optional, and the default is false).
To use it in your project, you only need to copy the following code, and call it as described above: