/// <summary> /// Updates the projectile. /// </summary> public bool Update(GameTime gameTime) { float elapsedTime = (float)gameTime.ElapsedGameTime.TotalSeconds; // Simple projectile physics. position += velocity * elapsedTime; velocity.Y -= elapsedTime * gravity; age += elapsedTime; // Update the particle emitter, which will create our particle trail. trailEmitter.Update(gameTime, position); // If enough time has passed, explode! Note how we pass our velocity // in to the AddParticle method: this lets the explosion be influenced // by the speed and direction of the projectile which created it. if (age > projectileLifespan) { for (int i = 0; i < numExplosionParticles; i++) { explosionParticles.AddParticle(position, velocity); } for (int i = 0; i < numExplosionSmokeParticles; i++) { explosionSmokeParticles.AddParticle(position, velocity); } return(false); } return(true); }
public override void Update(GameTime gameTime) { float particlesPerSecond = carActor.LinearVelocity.LengthSquared(); Vector3 pos = carActor.WorldTransform.Translation; smokeEmitter.Update(gameTime, pos, particlesPerSecond / 2f); //fireEmitter.Update(gameTime, pos, particlesPerSecond / 5f); foreach (ParticleSystem p in particleSystems) { p.Update(gameTime); } base.Update(gameTime); }