Game Development Reference
In-Depth Information
In order to test our animation class, we create a single
AnimationState
instance,
which we add to the game state manager:
gameStateManager.AddGameState("animationState",
new
AnimationState());
gameStateManager.SwitchTo("animationState");
Inside the
AnimationState
class, we create a
Player
instance, set it at the desired
position and add it to the game world:
Player player =
new
Player();
player.Position =
new
Vector2(50, 600);
this
.Add(player);
If you execute this program, you will see an animated character that you can control
with the left and right arrow keys.
26.7 What You Have Learned
In this chapter, you have learned:
•
how to create and control an animation;
•
how to build an animated game object consisting of multiple animations.