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 = new ExplosionManager( spriteSheet, new Rectangle(0, 100, 50, 50), 3, new Rectangle(0, 450, 2, 2));
In the
Update()
method of...