Example #1
0
 protected abstract bool UpdateParticle(Particle particle, GameTime time);
Example #2
0
 public void DeleteParticle(Particle particle)
 {
     spriteManager.DeleteSprite(particle.Sprite);
 }
Example #3
0
        protected override bool UpdateParticle(Particle particle, GameTime time)
        {
            if (particle.SpawnTime.TotalMilliseconds + ParticleLifetime < time.TotalGameTime.TotalMilliseconds)
                return false;

            particle.Position.UnderlyingVector += particle.Velocity * (float)time.ElapsedGameTime.TotalSeconds;

            if (InitialColor != FinalColor)
            {
                double fractionOfLifeLived = (double)(time.TotalGameTime - particle.SpawnTime).TotalMilliseconds / ParticleLifetime;
                Color color = new Color();
                color.R = Interpolate(fractionOfLifeLived, InitialColor.R, FinalColor.R);
                color.G = Interpolate(fractionOfLifeLived, InitialColor.G, FinalColor.G);
                color.B = Interpolate(fractionOfLifeLived, InitialColor.B, FinalColor.B);
                color.A = Interpolate(fractionOfLifeLived, InitialColor.A, FinalColor.A);
                particle.Color = color;
            }

            return true;
        }