View Full Version : Animation technique & transitions

08-05-2013, 11:28 AM
I couldn't find any resources in the forum on this topic so I decided to make one.

How would you guys suggest I do the animations with clanlib 2.3?
Since sprites contain frames with a lot of features it would be nice to use those. There are two ways I see this happening, each with its' set of problems.

1) I put all the animations "idle", "jump" etc. in one sprite and handle the frame changes when the animation reaches it's last frame. This would require custom implementation and would make some of the clanlib animation features unusable.

2) The second which sounds a lot easier to implement is to make a sprite for each animation and just change the "active" sprite when the animation changes. Here I expect to have a lot of animation cuts/glitches from not having proper transitions.

Also, I would love some advice on how to do animation transitions.

08-06-2013, 12:55 AM
The sprite animation system in ClanLib is a fairly simple system where switching between different actions assumes that an instant switch between animations will look alright. To my knowledge there is no 'animation queue' built into Sprite that allows you to switch at specific key frames.

Most games avoid relying too much on such a queue mostly because if an action animation is delayed, then strictly speaking the game logic code also would have to delay moving the sprite position on the screen. If the movement begins before a character is animating as moving, for example, then that may actually end up looking worse visually than if the animation switch was instant. Naturally this depends on what exactly is being animated and why.

Take 3D objects in World of Warcraft for instance. Based on the (unofficial) file format specs I once read and toying around inside the game, they seem to instantly switch animation on their 3D models when you start a new action, but then at the end of an action it might switch on to a different one. As an example, if you perform a /dance in WoW, then the character picks a random dance animation (out of maybe 5), then when that animation reaches its end the animation system automatically picks another random one. Other animations return to the 'default' stand still animation, such as a /lol command. Some animation speeds are fixed to frames per second, while other animations are relative to frames per units moved. This allows them to use the same animation no matter what speed a character moves (i.e. when shrunk by some shrink gun).

Because of the complexity and "it depends on what game", you may find that the built-in Sprite isn't advanced enough for your needs. The good news is that you can use Sprite in two modes: using the animation system, or drawing a specific frame and have your own system pick which frame to render next. That way you can still use the automatic texture atlas feature of Sprite and render batching, while building your own animation system on top.

Personally I would first try out if the instant switching actually looks bad for your type of game or not. You may be surprised at how forgiving human eyes are, especially when they are busy doing other things (such as playing your excellent game play). If you conclude it isn't good enough for your type of game, then you will probably have to build your own animation system (or submit patches to the built-in one).

08-06-2013, 08:27 AM
Thanks for the excellent reply. I feel like the animation transitions wont be that much of a problem as well.
I am going to try to define a new sprite for each animation I want an entity to have and then switch sprites instantly.