Game Development Reference
The first thing that grabs our eye is the Animation structure. This is the same structure
that we talked about earlier in this section. It is declared inside the Animator class be-
cause both the classes are coupled with each other by design. Furthermore, the Anima-
tion class will not be heavily used outside Animator . The next line contains the con-
structor's declaration, which expects a Sprite reference. This is the reference which ini-
tializes the member m_Sprite field.
Animator::CreateAnimation() creates an animation from the given parameters,
adds it to the list, and returns a reference to it. We will see exactly how that works in a
Animator::Update() handles all the logic behind choosing the right frame for the
right moment. Animator::SwitchAnimation(string) tries to switch the current
animation to an animation with the given name.
It's time to look into the implementation of these functions and the ways in which we can
use them. It makes sense to start from the constructor: