Time for action – spark effects
Add the
AddSparkEffect()
method to the "Public Methods" region of the EffectsManager class:public static void AddSparksEffect( Vector2 location, Vector2 impactVelocity) { int particleCount = rand.Next(10, 20); for (int x = 0; x < particleCount; x++) { Particle particle = new Particle( location - (impactVelocity / 60), Texture, ParticleFrame, randomDirection((float)rand.Next(10, 20)), Vector2.Zero, 60, 20, Color.Yellow, Color.Orange); Effects.Add(particle); } }
In the
LoadContent()
method of the Game1 class, initialize the EffectsManager after the Player class has been initialized:EffectsManager.Initialize( spriteSheet, new Rectangle(0, 288, 2, 2), new Rectangle(0, 256, 32, 32), 3);
In the
Update()
method of the Game1 class, update the EffectsManager after the player has been updated:EffectsManager...