Beispiel #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();
        }
        //======================================================[ Constructors & Methods ]
        public ParticleSystem(Game game) : base(game)
        {
            _groups = new Dictionary<string, EmitterGroup>();
            _modifiers = new List<Modifier>();
            _strips = new Dictionary<string, ImageStrip>();
            _trans = new Stack<Vector2>();

            ImageStrip strip = new ImageStrip("Default");
            strip.Asset = @"Resources\MPEDefaultParticle";
            strip.FrameWidth = strip.FrameHeight = 32;
            strip.Frames = 2;
            _strips.Add("Default", strip);

            EmitterGroup group = new EmitterGroup("Default");
            _groups.Add("Default", group);

            game.Components.Add(this);
        }
Beispiel #3
0
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            content = new ContentManager(Services);

            system = new ParticleSystem(this);
            emitter = new Emitter(1000);
            emitter.ParticleSpeed = 150f;
            emitter.ApplyModifier(new EmitterMouseController(true));

            //When creating an ImageStrip, you must supply 5 pieces of information. You must
            //give the ImageStrip a name, so that Emitters can identify it. You must specify
            //the number of frames in the ImageStrip, and also the width and height of each
            //frame. Finally you must specify the asset name, as specified in the content
            //pipeline.
            strip = new ImageStrip("custom");
            strip.Asset = "CustomParticleImage";
            strip.FrameHeight = 128;
            strip.FrameWidth = 128;
            strip.Frames = 4;

            //When it is done, you will add the ImageStrip to the ParticleSystem.
            system.ImageStrips.Add("custom", strip);

            //Then you will tell the Emitter to use this ImageStrip.
            emitter.ImageStrip = "custom";
            emitter.Frame = 2;

            //When using the ImageStrip, the Emitter will automatically render the
            //specified frame at the correct size, and the origin will always be at the
            //centre of the frame.

            system.AddEmitter(emitter);

            //If you make an error, either by telling the Emitter to use an ImageStrip that
            //doesn't exist, or telling it to use a frame that doesn't exist - The Emitter
            //will instead render Particles with an exclamation mark (!), to let you know
            //that there has been an error.
        }
        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="game">Instance of your Microsoft.Xna.Framework.Game object.</param>
        public ParticleSystem(Game game)
            : base(game)
        {
            _emitters = new List<Emitter>();
            _modifiers = new List<Modifier>();
            _content = new ContentManager(game.Services);

            //Create the default ImageStrip...
            _defaultImageStrip = new ImageStrip(game, @"Resources\DefaultParticle", 32, 32, 2);

            //Register self with game components...
            game.Components.Add(this);
        }