O'Reilly logo

XNA 4.0 Game Development by Example Beginner's Guide by Kurt Jaegers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required