diff --git a/examples/particles.php b/examples/particles.php index be0bf8fd..e1402869 100644 --- a/examples/particles.php +++ b/examples/particles.php @@ -33,15 +33,18 @@ game.stage.backgroundColor = 0x337799; - p = game.add.emitter(200, 100, 50); + p = game.add.emitter(200, 100, 250); // p.width = 200; // p.height = 200; // keys, frames, quantity, collide // p.makeParticles(['diamond', 'carrot', 'star']); - p.makeParticles('balls', [0,1,2,3,4,5]); - // p.makeParticles('pixies', [0,1,2,3]); + // p.makeParticles('balls', [0,1,2,3,4,5]); + p.makeParticles('pixies', [0,1,2,3]); + + p.minParticleScale = 0.1; + p.maxParticleScale = 0.5; // Steady constant stream at 250ms delay and 10 seconds lifespan // p.start(false, 10000, 250, 100); diff --git a/src/particles/arcade/Emitter.js b/src/particles/arcade/Emitter.js index a149c468..dd893630 100644 --- a/src/particles/arcade/Emitter.js +++ b/src/particles/arcade/Emitter.js @@ -46,15 +46,25 @@ Phaser.Particles.Arcade.Emitter = function (game, x, y, maxParticles) { */ this.maxParticleSpeed = new Phaser.Point(100, 100); + /** + * The minimum possible scale of a particle. + * The default value is 1. + */ + this.minParticleScale = 1; + + /** + * The maximum possible scale of a particle. + * The default value is 1. + */ + this.maxParticleScale = 1; + /** * The minimum possible angular velocity of a particle. The default value is -360. - * NOTE: rotating particles are more expensive to draw than non-rotating ones! */ this.minRotation = -360; /** * The maximum possible angular velocity of a particle. The default value is 360. - * NOTE: rotating particles are more expensive to draw than non-rotating ones! */ this.maxRotation = 360; @@ -325,7 +335,6 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { if (this.width > 1 || this.height > 1) { - // particle.reset(this.x - this.game.rnd.integerInRange(this.left, this.right), this.y - this.game.rnd.integerInRange(this.top, this.bottom)); particle.reset(this.x - this.game.rnd.integerInRange(this.left, this.right), this.y - this.game.rnd.integerInRange(this.top, this.bottom)); } else @@ -366,6 +375,12 @@ Phaser.Particles.Arcade.Emitter.prototype.emitParticle = function () { particle.body.angularVelocity = this.minRotation; } + if (this.minParticleScale !== 1 || this.maxParticleScale !== 1) + { + var scale = this.game.rnd.realInRange(this.minParticleScale, this.maxParticleScale); + particle.scale.setTo(scale, scale); + } + particle.body.drag.x = this.particleDrag.x; particle.body.drag.y = this.particleDrag.y;