/// <summary> /// This function generates a new array of sprites to attach to the emitter. /// </summary> /// <param name="Graphics"><para>Use FlxG.Content.Load<Texture2D>("Lemonade/ccc")</para><para>If you opted to not pre-configure an array of FlxSprite objects, you can simply pass in a particle image or sprite sheet.</para></param> /// <param name="Quantity">The number of particles to generate when using the "create from image" option.</param> /// <param name="Multiple">Whether the image in the Graphics param is a single particle or a bunch of particles (if it's a bunch, they need to be square!).</param> /// <param name="Collide">Whether the particles should be flagged as not 'dead' (non-colliding particles are higher performance). 0 means no collisions, 0-1 controls scale of particle's bounding box.</param> /// <param name="Bounce">Whether the particles should bounce after colliding with things. 0 means no bounce, 1 means full reflection.</param> /// <returns>This FlxEmitter instance (nice for chaining stuff together, if you're into that).</returns> public FlxEmitter createSprites(Texture2D Graphics, int Quantity, bool Multiple, float Collide, float Bounce) { members = new List <FlxObject>(); int r; FlxSprite s; int tf = 1; float sw; float sh; if (Multiple) { s = new FlxSprite(); s.loadGraphic(Graphics, true); tf = s.frames; } int i = 0; while (i < Quantity) { if ((Collide > 0) && (Bounce > 0)) { s = new FlxParticle(Bounce) as FlxSprite; } else { s = new FlxSprite(); } if (Multiple) { r = (int)(FlxU.random() * tf); //if(BakedRotations > 0) // s.loadRotatedGraphic(Graphics,BakedRotations,r); //else //{ s.loadGraphic(Graphics, true); s.frame = r; //} } else { //if(BakedRotations > 0) // s.loadRotatedGraphic(Graphics,BakedRotations); //else s.loadGraphic(Graphics); } if (Collide > 0) { sw = s.width; sh = s.height; s.width = (int)(s.width * Collide); s.height = (int)(s.height * Collide); s.offset.X = (int)(sw - s.width) / 2; s.offset.Y = (int)(sh - s.height) / 2; s.solid = true; } else { s.solid = false; } s.exists = false; s.scrollFactor = scrollFactor; add(s); i++; } return(this); }
public FlxEmitter createSprites(Texture2D Graphics, int Quantity, bool Multiple, float Collide, float Bounce) { members = new List<FlxObject>(); int r; FlxSprite s; int tf = 1; float sw; float sh; if(Multiple) { s = new FlxSprite(); s.loadGraphic(Graphics,true); tf = s.frames; } int i = 0; while(i < Quantity) { if((Collide > 0) && (Bounce > 0)) s = new FlxParticle(Bounce) as FlxSprite; else s = new FlxSprite(); if(Multiple) { r = (int)(FlxU.random()*tf); //if(BakedRotations > 0) // s.loadRotatedGraphic(Graphics,BakedRotations,r); //else //{ s.loadGraphic(Graphics,true); s.frame = r; //} } else { //if(BakedRotations > 0) // s.loadRotatedGraphic(Graphics,BakedRotations); //else s.loadGraphic(Graphics); } if(Collide > 0) { sw = s.width; sh = s.height; s.width = (int)(s.width * Collide); s.height = (int)(s.height * Collide); s.offset.X = (int)(sw-s.width)/2; s.offset.Y = (int)(sh-s.height)/2; s.solid = true; } else s.solid = false; s.exists = false; s.scrollFactor = scrollFactor; add(s); i++; } return this; }