Time for action – building a new Sprite class

  1. Add a new class called "Sprite" to the Robot Rampage project.
  2. Add the following using directives to the top of the class file:
    using Microsoft.Xna.Framework.Graphics;
    using Microsoft.Xna.Framework;
  3. Add declarations to the Sprite class:
    #region Declarations public Texture2D Texture; private Vector2 worldLocation = Vector2.Zero; private Vector2 velocity = Vector2.Zero; private List<Rectangle> frames = new List<Rectangle>(); private int currentFrame; private float frameTime = 0.1f; private float timeForCurrentFrame = 0.0f; private Color tintColor = Color.White; private float rotation = 0.0f; public bool Expired = false; public bool Animate = true; public bool AnimateWhenStopped = true; public bool Collidable ...

Get XNA 4.0 Game Development by Example Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.