Time for action – adding animation frames
Add the
AddFrame()
method to the Sprite class:public void AddFrame(Rectangle frameRectangle) { frames.Add(frameRectangle); }
What just happened?
Adding a frame to the sprite's animation is as simple as adding the corresponding Rectangle
to the frames
list. When the animation is updated, the frame value will be compared to the number of entries in frames (via frames.Count
) eliminating the need to store the number of animation frames as a separate value.