mirror of
https://github.com/photonstorm/phaser
synced 2024-11-30 00:21:04 +00:00
fire returns a boolean. Re-ordered ops and added death zone check on spawn.
This commit is contained in:
parent
f1ab07d9b2
commit
6abb358e50
1 changed files with 32 additions and 18 deletions
|
@ -400,6 +400,8 @@ var Particle = new Class({
|
||||||
*
|
*
|
||||||
* @param {number} [x] - The x coordinate to launch this Particle from.
|
* @param {number} [x] - The x coordinate to launch this Particle from.
|
||||||
* @param {number} [y] - The y coordinate to launch this Particle from.
|
* @param {number} [y] - The y coordinate to launch this Particle from.
|
||||||
|
*
|
||||||
|
* @return {boolean} `true` if the Particle is alive, or `false` if it was spawned inside a DeathZone.
|
||||||
*/
|
*/
|
||||||
fire: function (x, y)
|
fire: function (x, y)
|
||||||
{
|
{
|
||||||
|
@ -458,6 +460,23 @@ var Particle = new Class({
|
||||||
this.lifeCurrent = this.life;
|
this.lifeCurrent = this.life;
|
||||||
this.lifeT = 0;
|
this.lifeT = 0;
|
||||||
|
|
||||||
|
this.delayCurrent = ops.delay.onEmit(this, 'delay');
|
||||||
|
|
||||||
|
this.scaleX = ops.scaleX.onEmit(this, 'scaleX');
|
||||||
|
this.scaleY = (ops.scaleY.active) ? ops.scaleY.onEmit(this, 'scaleY') : this.scaleX;
|
||||||
|
|
||||||
|
this.angle = ops.rotate.onEmit(this, 'rotate');
|
||||||
|
|
||||||
|
this.rotation = DegToRad(this.angle);
|
||||||
|
|
||||||
|
// Check we didn't spawn in the middle of a DeathZone
|
||||||
|
if (this.delayCurrent === 0 && emitter.getDeathZone(this))
|
||||||
|
{
|
||||||
|
this.lifeCurrent = 0;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var sx = ops.speedX.onEmit(this, 'speedX');
|
var sx = ops.speedX.onEmit(this, 'speedX');
|
||||||
var sy = (ops.speedY.active) ? ops.speedY.onEmit(this, 'speedY') : sx;
|
var sy = (ops.speedY.active) ? ops.speedY.onEmit(this, 'speedY') : sx;
|
||||||
|
|
||||||
|
@ -492,14 +511,6 @@ var Particle = new Class({
|
||||||
this.maxVelocityX = ops.maxVelocityX.onEmit(this, 'maxVelocityX');
|
this.maxVelocityX = ops.maxVelocityX.onEmit(this, 'maxVelocityX');
|
||||||
this.maxVelocityY = ops.maxVelocityY.onEmit(this, 'maxVelocityY');
|
this.maxVelocityY = ops.maxVelocityY.onEmit(this, 'maxVelocityY');
|
||||||
|
|
||||||
this.delayCurrent = ops.delay.onEmit(this, 'delay');
|
|
||||||
|
|
||||||
this.scaleX = ops.scaleX.onEmit(this, 'scaleX');
|
|
||||||
this.scaleY = (ops.scaleY.active) ? ops.scaleY.onEmit(this, 'scaleY') : this.scaleX;
|
|
||||||
|
|
||||||
this.angle = ops.rotate.onEmit(this, 'rotate');
|
|
||||||
this.rotation = DegToRad(this.angle);
|
|
||||||
|
|
||||||
this.bounce = ops.bounce.onEmit(this, 'bounce');
|
this.bounce = ops.bounce.onEmit(this, 'bounce');
|
||||||
|
|
||||||
this.alpha = ops.alpha.onEmit(this, 'alpha');
|
this.alpha = ops.alpha.onEmit(this, 'alpha');
|
||||||
|
@ -512,6 +523,8 @@ var Particle = new Class({
|
||||||
{
|
{
|
||||||
this.tint = ops.tint.onEmit(this, 'tint');
|
this.tint = ops.tint.onEmit(this, 'tint');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -677,17 +690,11 @@ var Particle = new Class({
|
||||||
|
|
||||||
if (emitter.bounds)
|
if (emitter.bounds)
|
||||||
{
|
{
|
||||||
|
this.bounce = ops.bounce.onUpdate(this, 'bounce', t, this.bounce);
|
||||||
|
|
||||||
this.checkBounds(emitter);
|
this.checkBounds(emitter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (emitter.getDeathZone(this))
|
|
||||||
{
|
|
||||||
this.lifeCurrent = 0;
|
|
||||||
|
|
||||||
// No need to go any further, particle has been killed
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.scaleX = ops.scaleX.onUpdate(this, 'scaleX', t, this.scaleX);
|
this.scaleX = ops.scaleX.onUpdate(this, 'scaleX', t, this.scaleX);
|
||||||
this.scaleY = this.scaleX;
|
this.scaleY = this.scaleX;
|
||||||
|
|
||||||
|
@ -697,8 +704,17 @@ var Particle = new Class({
|
||||||
}
|
}
|
||||||
|
|
||||||
this.angle = ops.rotate.onUpdate(this, 'rotate', t, this.angle);
|
this.angle = ops.rotate.onUpdate(this, 'rotate', t, this.angle);
|
||||||
|
|
||||||
this.rotation = DegToRad(this.angle);
|
this.rotation = DegToRad(this.angle);
|
||||||
|
|
||||||
|
if (emitter.getDeathZone(this))
|
||||||
|
{
|
||||||
|
this.lifeCurrent = 0;
|
||||||
|
|
||||||
|
// No need to go any further, particle has been killed
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
this.alpha = ops.alpha.onUpdate(this, 'alpha', t, this.alpha);
|
this.alpha = ops.alpha.onUpdate(this, 'alpha', t, this.alpha);
|
||||||
|
|
||||||
if (ops.color.active)
|
if (ops.color.active)
|
||||||
|
@ -710,8 +726,6 @@ var Particle = new Class({
|
||||||
this.tint = ops.tint.onUpdate(this, 'tint', t, this.tint);
|
this.tint = ops.tint.onUpdate(this, 'tint', t, this.tint);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bounce = ops.bounce.onUpdate(this, 'bounce', t, this.bounce);
|
|
||||||
|
|
||||||
this.lifeCurrent -= delta;
|
this.lifeCurrent -= delta;
|
||||||
|
|
||||||
return (this.lifeCurrent <= 0);
|
return (this.lifeCurrent <= 0);
|
||||||
|
|
Loading…
Reference in a new issue