Modifying the Sprite Class
The first thing you'll need to do in the Sprite
class is change the namespace of the class from AnimatedSprites
to Catch
:
namespace Catch
In this game, players will take turns chasing each other. There will be two sprite
objects: a gears sprite and a dynamite sprite. The dynamite sprite will always chase
the gears sprite around the screen. Because players will be switching back and forth
from gears sprites to dynamite sprites, you'll need to expose a few variables with
auto-implemented properties. To do this, add the following class-level variables to
your Sprite
class:
public Texture2D textureImage { get; set; } public Point sheetSize { get; set; } public Vector2 speed { get; set; } public Vector2 originalSpeed { get; set; }
You're also going to need to set the positions of the sprites between rounds, so
that the chaser and chased players don't start next to each other. Change the
GetPosition
property accessor to Position
and add a set
accessor:
public Vector2 Position { get { return position; } set { position = value; } }
Get Learning XNA 3.0 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.