Time for action – building the Animation class
In the Gemstone Hunter project, add a new class file called
AnimationStrip.cs
.Add the following
using
directives to the AnimationStrip class:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
Modify the declaration of the AnimationStrip class to make it a public class:
public class AnimationStrip
Add declarations to the AnimationStrip class:
#region Declarations private Texture2D texture; private int frameWidth; private int frameHeight; private float frameTimer = 0f; private float frameDelay = 0.05f; private int currentFrame; private bool loopAnimation = true; private bool finishedPlaying = false; private string name; private string nextAnimation; #endregion
Add properties to the AnimationStrip class:
#region Properties public int FrameWidth { get { return frameWidth; } set { frameWidth = value; } } public int FrameHeight { get { return frameHeight; } set { frameHeight = value; } } public Texture2D Texture...