Time for action – updating and drawing explosions
- Add the
Update()
method to the ExplosionManager class:public void Update(GameTime gameTime) { for (int x = ExplosionParticles.Count-1; x >= 0; x--) { if (ExplosionParticles[x].IsActive) { ExplosionParticles[x].Update(gameTime); } else { ExplosionParticles.RemoveAt(x); } } }
- Add the
Draw()
method to the ExplosionManager class:public void Draw(SpriteBatch spriteBatch) { foreach (Particle particle in ExplosionParticles) { particle.Draw(spriteBatch); } }
- Add an instance of the ExplosionManager to the declarations area of the
Game1.cs
class file:ExplosionManager explosionManager;
- Still in the Game1 class, add the initialization of the
explosionManager
object to theLoadContent()
method:explosionManager ...
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.