Game Development Reference
In-Depth Information
Building an animator
It is important to know exactly what we are doing before we start doing it, so let's list the
specifications for our animator:
• The animator needs to animate a sprite from a single object or multiple texture ob-
• Our animator needs to support animations with variable durations and a number of
• Our animator should hold multiple animations
• It needs to be able to switch between animations
• Each sprite should have its own animator object
• It should be easy to use
• Our animator needs to be able to perform automatic texture rectangle generation
It seems quite straightforward, doesn't it? Since we want to perform multiple animations
per animator, we have to create a struct animation to hold each animation property. We
are using struct rather than class with proper encapsulation to reduce the code size. In
both cases though, each animation should have a duration time, a list of frames, a texture
(used by the animation), loop information (does it loop?), and a name handle, which is
used to reference that animation. Based on this design, here is what our structure should
look like:
Search WWH ::

Custom Search