Time for action – adding animation frames
Add the
AddFrame()
method to theSprite
class:Public Sub AddFrame(frameRectangle As Rectangle) frames.Add(frameRectangle) End Sub
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.