fliXNA_xbox.FlxParticle.loadParticleGraphic C# (CSharp) Méthode

loadParticleGraphic() public méthode

Internal function used by FlxEmitter to create the particles
public loadParticleGraphic ( Microsoft.Xna.Framework.Graphics.Texture2D Graphic, float Rotation, float Width, float Height ) : FlxSprite
Graphic Microsoft.Xna.Framework.Graphics.Texture2D
Rotation float
Width float
Height float
Résultat FlxSprite
        public FlxSprite loadParticleGraphic(Texture2D Graphic, float Rotation, float Width = 0, float Height = 0)
        {
            rotateBy = Rotation * 0.0174532925f;
            texture = Graphic;
            int numFrames = (int)FlxU.floor(texture.Width / texture.Height);

            if (Width == 0 || Height == 0)
            {
                Width = texture.Height;
                Height = Width;
            }
            frameWidth = width = Width;
            frameHeight = height = Height;
            List<FlxRect> _draws = new List<FlxRect>();
            for (int i = 0; i < numFrames; i++)
            {
                FlxRect textureArea = new FlxRect(i * height, 0, width, height);
                _draws.Add(textureArea);
            }
            int di;// = (int)Math.Round(FlxU.randomBetween(0, numFrames));
            Random r = new Random();
            di = r.Next(numFrames);
            particleRect = _draws[di];
            //FlxRect t = _draws[di];
            sourceRect = new FlxRect(particleRect.x, particleRect.y, particleRect.width, particleRect.height);
            return this;
        }

Usage Example

Exemple #1
0
        /// <summary>
        /// Create the particles to be used
        /// </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>FlxEmitter</returns>
        public FlxEmitter makeParticles(Texture2D Graphic, bool Multiple = false, uint Quantity = 50, float Rotation = 1f, float Collide = 0.8f)
        {
            maxSize = Quantity;
            FlxParticle particle;
            uint        i = 0;

            while (i < Quantity)
            {
                particle = new FlxParticle();
                if (Multiple)
                {
                    particle.loadParticleGraphic(Graphic, Rotation);
                }
                else
                {
                    particle.loadGraphic(Graphic);
                }
                if (Collide > 0)
                {
                    particle.width  *= Collide;
                    particle.height *= Collide;
                    particle.centerOffsets();
                }
                else
                {
                    particle.allowCollisions = FlxObject.NONE;
                }
                particle.exists = false;
                add(particle);
                i++;
            }
            return(this);
        }
All Usage Examples Of fliXNA_xbox.FlxParticle::loadParticleGraphic