Up until now, all the animations we have created are based on changing attributes, such as the position, color value, and size, of still images. Therefore, our next enhancement is targeted towards the game objects that inhabit the game world of Canyon Bunny. We want to breathe life into the gold coin and bunny head game objects by creating several animations that are built from sequences of individual images. The resulting effect is very similar in comparison to an ordinary flip book where multiple images are perceived as a continuous animation when shown in rapid succession.
Libgdx provides a class called
Animation that helps us define image sequences and also helps us to pick the right (key) frame from a sequence at a specific time which, for example, depends on the desired frame rate for playback. There is some clever mathematics and state keeping involved for finding the right frame in an efficient way. Luckily, the
Animation class saves us from...