Ejemplo n.º 1
0
        protected override void Initialize()
        {
            Emitter example = new CircleEmitter(150, 0f, false, CircleEmitter.RadialSpread.FromCenter);
            example.DischargeQuantity = 3;
            example.ParticleLifespan = 6000;
            example.ParticleSpeed = 40f;
            example.ParticleSpeedRange = 40f;
            example.Position = new Vector2(320f, 240f);

            example.ApplyModifier(new TimedTriggerController(200f));
            example.ApplyModifier(new Opacity3Modifier(0f, .5f, .25f, 0f, 128));
            example.ApplyModifier(new Color3Modifier(Color.Firebrick.ToVector3(), Color.Goldenrod.ToVector3(), 0.75f, Color.WhiteSmoke.ToVector3(), 128));
            example.ApplyModifier(new Scale2Modifier(1f, 3f));
            example.ApplyModifier(new ParticleRotationModifier(.05f));

            ImageStrip xtra = new ImageStrip("xtra");
            xtra.Asset = @"Resources\xtra1";
            xtra.FrameHeight = 128;
            xtra.Frames = 4;
            xtra.FrameWidth = 128;

            system.ImageStrips.Add("xtra", xtra);

            example.ImageStrip = "xtra";
            example.Frame = 3;
            
            system.AddEmitter(example);

            base.Initialize();
        }
Ejemplo n.º 2
0
        protected override void Initialize()
        {
            base.Initialize();

            //The SprayEmitter emits Particles in a fountain-like manner. You can adjust the
            //angle of the spray, and also the spread. The SprayEmitter constructor takes
            //both of its angle arguments in radians.
            spray = new SprayEmitter(1000, MathHelper.ToRadians(-90f), MathHelper.ToRadians(30f));
            spray.Position = new Vector2(400f, 550f);
            spray.ParticleSpeed = 250f;
            spray.ParticleSpeedRange = 100f;
            spray.DischargeQuantity = 3;
            spray.ParticleColor = Color.Red;

            //The CircleEmitter emits Particles from a random position inside a circle. It
            //can also emit Particles only from the circles edge, like a ring shape. You can
            //set the spawned Particles to face away from the circles center, or in a
            //random direction.
            circle = new CircleEmitter(1000, 50f, false, CircleEmitter.RadialSpread.FromCenter);
            circle.Position = new Vector2(150f, 350f);
            circle.ParticleSpeed = 100f;
            circle.DischargeQuantity = 3;
            circle.ParticleColor = Color.Blue;

            //The SpiralEmitter can emit Particles in a spiral shape. You can adjust the
            //number of segments in the spiral, and also the direction of the spiral.
            //In this example, we have set the DischargeQuantity to be the same as spiral
            //segments, so at each trigger we will get 1 complete ring.
            spiral = new SpiralEmitter(1000, 150f, 32, SpiralEmitter.SpiralDirection.Clockwise);
            spiral.Position = new Vector2(650f, 350f);
            spiral.ParticleSpeed = -100f;
            spiral.DischargeQuantity = 32;
            spiral.ParticleColor = Color.Green;

            //The LineEmitter spawns Particles from a random position along a line. You can
            //change the length, and rotation of the line. It could be useful for creating
            //rain or snow effects.
            line = new LineEmitter(1000, 800f);
            line.Position = new Vector2(400f, 0f);
            line.ParticleSpeed = 150f;
            line.DischargeQuantity = 3;

            //The TimeTriggerController Modifier causes the Emitter to trigger at the
            //specified interval.
            //Unfortunately there is a bug in this Modifier which causes it to only
            //affect 1 Emitter at a time. It will be fixed in next version.
            spray.ApplyModifier(new TimedTriggerController(50f));
            circle.ApplyModifier(new TimedTriggerController(50f));
            spiral.ApplyModifier(new TimedTriggerController(250f));
            line.ApplyModifier(new TimedTriggerController(50f));

            //And of course, we need to add the Emitters to the ParticleSystem.
            system.AddEmitter(spray);
            system.AddEmitter(circle);
            system.AddEmitter(spiral);
            system.AddEmitter(line);
        }