Time for action – constructing the Particle class
- Add a new class called
Particle.cs
to the Asteroid Belt Assault project. - Insert the standard
using
directives at the top of the class:using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
- Modify the declaration of the class by adding
: Sprite
to the end:class Particle : Sprite
- Add declarations to represent the additional members of the Particle class (beyond those of the Sprite class):
private Vector2 acceleration; private float maxSpeed; private int initialDuration; private int remainingDuration; private Color initialColor; private Color finalColor;
- Add properties to access the information about the underlying members:
public int ElapsedDuration { get { return initialDuration - remainingDuration; ...
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.