Particle.Emitter will now automatically set particle.body.skipQuadTree to true to help with collision speeds within Arcade Physics.

Particle.Emitter.explode (or `Emitter.start` with the `explode` parameter set to `true`) will immediately emit the required quantity of particles and not delay until the next frame to do so. This means you can re-use a single emitter across multiple places in your game that require explode-style emissions, just by adjusting the `emitter.x` and `emitter.y` properties before calling explode (thanks Insanehero)
This commit is contained in:
photonstorm 2014-10-27 23:29:43 +00:00
parent a471cfc235
commit dfa442db93
2 changed files with 20 additions and 35 deletions

View file

@ -86,6 +86,8 @@ Version 2.1.4 - "Bethal" - in development
* Cache.getUrl is deprecated. The same method is now available as Cache.getURL.
* Loader.useXDomainRequest used to be enabled automatically for IE9 but is now always set to `false`. Please enable it only if you know your server set-up / CDN requires it, as some most certainly do, but we're finding them to be less and less used these days, so we feel it's safe to now disable this by default (#1248)
* Game.destroy now destroys either the WebGLRenderer or CanvasRenderer, whichever Pixi was using.
* Particle.Emitter will now automatically set `particle.body.skipQuadTree` to `true` to help with collision speeds within Arcade Physics.
* Particle.Emitter.explode (or `Emitter.start` with the `explode` parameter set to `true`) will immediately emit the required quantity of particles and not delay until the next frame to do so. This means you can re-use a single emitter across multiple places in your game that require explode-style emissions, just by adjusting the `emitter.x` and `emitter.y` properties before calling explode (thanks Insanehero)
### Bug Fixes

View file

@ -251,40 +251,21 @@ Phaser.Particles.Arcade.Emitter.prototype.constructor = Phaser.Particles.Arcade.
*/
Phaser.Particles.Arcade.Emitter.prototype.update = function () {
if (this.on)
if (this.on && this.game.time.now >= this._timer)
{
if (this._explode)
this.emitParticle();
this._counter++;
if (this._quantity > 0)
{
this._counter = 0;
do
if (this._counter >= this._quantity)
{
this.emitParticle();
this._counter++;
}
while (this._counter < this._quantity);
this.on = false;
}
else
{
if (this.game.time.now >= this._timer)
{
this.emitParticle();
this._counter++;
if (this._quantity > 0)
{
if (this._counter >= this._quantity)
{
this.on = false;
}
}
this._timer = this.game.time.now + this.frequency;
this.on = false;
}
}
this._timer = this.game.time.now + this.frequency;
}
var i = this.children.length;
@ -351,6 +332,7 @@ Phaser.Particles.Arcade.Emitter.prototype.makeParticles = function (keys, frames
}
particle.body.collideWorldBounds = collideWorldBounds;
particle.body.skipQuadTree = true;
particle.exists = false;
particle.visible = false;
@ -438,24 +420,25 @@ Phaser.Particles.Arcade.Emitter.prototype.start = function (explode, lifespan, f
this.revive();
this.visible = true;
this.on = true;
this._explode = explode;
this.lifespan = lifespan;
this.frequency = frequency;
if (explode || forceQuantity)
{
this._quantity = quantity;
for (var i = 0; i < quantity; i++)
{
this.emitParticle();
}
}
else
{
this.on = true;
this._quantity += quantity;
this._counter = 0;
this._timer = this.game.time.now + frequency;
}
this._counter = 0;
this._timer = this.game.time.now + frequency;
};
/**