示例#1
0
        //add a bi-direction particle spread at the center of a pair of objects
        static void addScrapeEffect(GameObjectPair objects)
        {
            Vector2 normal = GameObject.GetNormal(objects);

            //first emitter
            ParticleEmitter temp1 = new ParticleEmitter(
                SCRAPE_PARTICLES,
                objects.CenterPoint(), //use center of both as reference
                ExplosionParticleTextures,
                SCRAPE_COLORS.ToList<Color>(),
                SCRAPE_FRAMES_TO_LIVE,
                true,
                true, //fading enabled
                PARTICLE_TIME_TO_EMIT,
                SCRAPE_PARTICLES / PARTICLE_TIME_TO_EMIT,
                SCRAPE_EJECTION_SPEED,
                PARTICLERANDOMIZATION,
                MathHelper.ToDegrees(normal.RotateTo()), //get the velocity angle + 90 degrees
                SCRAPE_SPRAY);

            //second emitter
            ParticleEmitter temp2 = new ParticleEmitter(
                SCRAPE_PARTICLES,
                objects.CenterPoint(),
                ExplosionParticleTextures,
                SCRAPE_COLORS.ToList<Color>(),
                SCRAPE_FRAMES_TO_LIVE,
                true,
                true,
                PARTICLE_TIME_TO_EMIT,
                SCRAPE_PARTICLES / PARTICLE_TIME_TO_EMIT,
                SCRAPE_EJECTION_SPEED,
                PARTICLERANDOMIZATION,
                MathHelper.ToDegrees(normal.RotateTo() + 180),
                SCRAPE_SPRAY);

            //inherit velocities
            Vector2 temp = objects.Object1.Velocity.Center(objects.Object2.Velocity);
            temp1.VelocityToInherit = temp;
            temp2.VelocityToInherit = temp;

            //set depths
            temp1.ParticleDrawDepth = EFFECT_DRAW_DEPTH;
            temp2.ParticleDrawDepth = EFFECT_DRAW_DEPTH;

            emitters.Add(temp1);
            emitters.Add(temp2);
        }
示例#2
0
 //get the normal of a pair
 public static Vector2 GetNormal(GameObjectPair objects)
 {
     Vector2 normal = objects.Object2.WorldCenter - objects.Object1.WorldCenter;
     normal.Normalize();
     return normal;
 }