Beispiel #1
0
        /// <summary>
        /// Clean up memory.
        /// </summary>
        public override void destroy()
        {
            screen.destroy();
            screen   = null;
            Target   = null;
            Scroll   = null;
            Deadzone = null;
            Bounds   = null;
            Buffer   = null;
            //_flashBitmap = null;
            //_flashRect = null;
            //_flashPoint = null;
            fxFlashComplete = null;
            fxFadeComplete  = null;
            fxShakeComplete = null;
            fxShakeOffset   = null;
            //_fill = null;

            base.destroy();
        }
Beispiel #2
0
        /// <summary>
        /// This function generates a new array of particle sprites to attach to the emitter.
        /// </summary>
        /// <param name="graphics">Texture for the particles - can be one square or a spritesheet.  Set Multiple to true if it is a spritesheet and it will automatically create the particles as long as each frame on the spritesheet is square</param>
        /// <param name="Multiple">Whether or not the Texture contains multiple sprites for particles</param>
        /// <param name="Quantity">The number of particles to generate</param>
        /// <param name="Rotation">The amount of rotation in degrees per frame, so keep this number low</param>
        /// <param name="Collide">The collidability of the particle, 1 = Full and 0 = None</param>
        /// <returns>This FlxEmitter instance (nice for chaining stuff together, if you're into that).</returns>
        //public FlxEmitter makeParticles(Texture2D graphics, bool Multiple=false, uint Quantity = 50, float Rotation = 1f, float Collide = 0.8f)
        public FlxEmitter makeParticles(string graphics, uint Quantity = 50, uint BakedRotations = 0, bool Multiple = false, float Collide = 0.8f)
        {
            maxSize = Quantity;
            uint totalFrames = 0;

            if (Multiple) {
                FlxSprite sprite = new FlxSprite();
                sprite.loadGraphic(graphics,true);
                totalFrames = sprite.Frames;
                sprite.destroy();
            }

            uint randomFrame;
            FlxParticle particle;
            int i = 0;

            while(i < Quantity)
            {
                particle = new FlxParticle();
                /*
                if(particleClass == null)
                    particle = new FlxParticle();
                else
                    particle = new particleClass();
                */
                if(Multiple)
                {
                    randomFrame = (uint)(FlxG.random()*totalFrames);
                    if(BakedRotations > 0)
                        particle.loadRotatedGraphic(graphics,BakedRotations,(int)randomFrame);
                    else
                    {
                        particle.loadGraphic(graphics,true);
                        particle.Frame = (int)randomFrame;
                    }
                }
                else
                {
                    if(BakedRotations > 0)
                        particle.loadRotatedGraphic(graphics,BakedRotations);
                    else
                        particle.loadGraphic(graphics);
                }
                if(Collide > 0)
                {
                    particle.Width *= Collide;
                    particle.Height *= Collide;
                    particle.centerOffsets();
                }
                else
                    particle.AllowCollisions = FlxObject.None;
                particle.Exists = false;
                add(particle);
                i++;
            }

            return this;
        }
Beispiel #3
0
        /// <summary>
        /// This function generates a new array of particle sprites to attach to the emitter.
        /// </summary>
        /// <param name="graphics">Texture for the particles - can be one square or a spritesheet.  Set Multiple to true if it is a spritesheet and it will automatically create the particles as long as each frame on the spritesheet is square</param>
        /// <param name="Multiple">Whether or not the Texture contains multiple sprites for particles</param>
        /// <param name="Quantity">The number of particles to generate</param>
        /// <param name="Rotation">The amount of rotation in degrees per frame, so keep this number low</param>
        /// <param name="Collide">The collidability of the particle, 1 = Full and 0 = None</param>
        /// <returns>This FlxEmitter instance (nice for chaining stuff together, if you're into that).</returns>
        //public FlxEmitter makeParticles(Texture2D graphics, bool Multiple=false, uint Quantity = 50, float Rotation = 1f, float Collide = 0.8f)
        public FlxEmitter makeParticles(string graphics, uint Quantity = 50, uint BakedRotations = 0, bool Multiple = false, float Collide = 0.8f)
        {
            maxSize = Quantity;
            uint totalFrames = 0;

            if (Multiple)
            {
                FlxSprite sprite = new FlxSprite();
                sprite.loadGraphic(graphics, true);
                totalFrames = sprite.Frames;
                sprite.destroy();
            }

            uint        randomFrame;
            FlxParticle particle;
            int         i = 0;

            while (i < Quantity)
            {
                particle = new FlxParticle();

                /*
                 * if(particleClass == null)
                 *      particle = new FlxParticle();
                 * else
                 *      particle = new particleClass();
                 */
                if (Multiple)
                {
                    randomFrame = (uint)(FlxG.random() * totalFrames);
                    if (BakedRotations > 0)
                    {
                        particle.loadRotatedGraphic(graphics, BakedRotations, (int)randomFrame);
                    }
                    else
                    {
                        particle.loadGraphic(graphics, true);
                        particle.Frame = (int)randomFrame;
                    }
                }
                else
                {
                    if (BakedRotations > 0)
                    {
                        particle.loadRotatedGraphic(graphics, BakedRotations);
                    }
                    else
                    {
                        particle.loadGraphic(graphics);
                    }
                }
                if (Collide > 0)
                {
                    particle.Width  *= Collide;
                    particle.Height *= Collide;
                    particle.centerOffsets();
                }
                else
                {
                    particle.AllowCollisions = FlxObject.None;
                }
                particle.Exists = false;
                add(particle);
                i++;
            }

            return(this);
        }