Time for action – declarations for the Sprite class

  1. Add a new class to the project called Sprite.cs.
  2. Update the class' using area to include:
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Graphics;
  3. Add the following declarations to the Sprite class:
    public Texture2D Texture; protected List<Rectangle> frames = new List<Rectangle>(); private int frameWidth = 0; private int frameHeight = 0; private int currentFrame; private float frameTime = 0.1f; private float timeForCurrentFrame = 0.0f; private Color tintColor = Color.White; private float rotation = 0.0f; public int CollisionRadius = 0; public int BoundingXPadding = 0; public int BoundingYPadding = 0; protected Vector2 location = Vector2.Zero; protected Vector2 velocity = Vector2.Zero; ...

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.