mirror of
https://github.com/photonstorm/phaser
synced 2024-11-25 22:20:44 +00:00
The Particle DeathZone.willKill
method now takes a Particle
instance as its only parameter, instead of x and y coordinates, allowing you to perform more complex checks before deciding if the Particle should be killed, or not.
This commit is contained in:
parent
e83ea01fc5
commit
1193f8811f
2 changed files with 6 additions and 6 deletions
|
@ -1910,9 +1910,8 @@ var ParticleEmitter = new Class({
|
|||
for (var i = 0; i < zones.length; i++)
|
||||
{
|
||||
var zone = zones[i];
|
||||
var pos = particle.worldPosition;
|
||||
|
||||
if (zone.willKill(pos.x, pos.y))
|
||||
if (zone.willKill(particle))
|
||||
{
|
||||
this.emit(Events.DEATH_ZONE, this, particle, zone);
|
||||
|
||||
|
|
|
@ -56,14 +56,15 @@ var DeathZone = new Class({
|
|||
* @method Phaser.GameObjects.Particles.Zones.DeathZone#willKill
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} x - The x coordinate of the Particle to be checked against this zone.
|
||||
* @param {number} y - The y coordinate of the Particle to be checked against this zone.
|
||||
* @param {Phaser.GameObjects.Particles.Particle} particle - The particle to test against this Death Zones.
|
||||
*
|
||||
* @return {boolean} Return `true` if the Particle is to be killed, otherwise return `false`.
|
||||
*/
|
||||
willKill: function (x, y)
|
||||
willKill: function (particle)
|
||||
{
|
||||
var withinZone = this.source.contains(x, y);
|
||||
var pos = particle.worldPosition;
|
||||
|
||||
var withinZone = this.source.contains(pos.x, pos.y);
|
||||
|
||||
return (withinZone && this.killOnEnter || !withinZone && !this.killOnEnter);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue