mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Added ability to Scale particles when emitted.
This commit is contained in:
parent
4f950ae801
commit
609ea7ec8f
2 changed files with 24 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue