-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Description
Version
- Phaser Version: Phaser 3.86.0
- Operating system: Windows
- Browser: Chrome
Description
Adding a death zone to a particle emitter doesn't cause the particles to die if they enter the death zone (for onEnter
death zones) or if they leave an onLeave
death zone.
Example Test Code
This example shows it not working: https://phaser.io/examples/v3.85.0/game-objects/particle-emitter/view/multiple-death-zones
Also this example for onLeave
death zones (which cause the particles to not work at all from what I can tell):
export default class ParticleDeathZoneIssue extends Phaser.Scene {
preload() {
this.load.atlas('flares', 'assets/images/flares.png', 'assets/images/flares.json');
}
create() {
const rect = new Phaser.Geom.Rectangle(this.scale.width / 2 - 200, this.scale.height / 2 - 200, 400, 400);
const emitter = this.add.particles(this.scale.width / 2, this.scale.height / 2, 'flares', {
frame: ['red', 'green', 'blue'],
speed: 300,
gravityY: 400,
lifespan: 4000,
scale: 0.4,
blendMode: 'ADD',
deathZone: {
type: 'onLeave',
source: rect
}
});
const graphics = this.add.graphics();
graphics.lineStyle(1, 0x00ff00, 1);
graphics.strokeRectShape(rect);
}
}
Additional Information
If you set the particle emitter to follow an object, the death zones "sort of" work again.
export default class ParticleDeathZoneIssue extends Phaser.Scene {
preload() {
this.load.atlas('flares', 'assets/images/flares.png', 'assets/images/flares.json');
}
create() {
this.followObj = this.add.circle(0,0,10,0xff0000);
const rect = new Phaser.Geom.Rectangle(this.scale.width / 2 - 200, this.scale.height / 2 - 200, 400, 400);
const emitter = this.add.particles(0,0, 'flares', {
frame: ['red', 'green', 'blue'],
speed: 300,
gravityY: 400,
lifespan: 4000,
scale: 0.4,
blendMode: 'ADD',
deathZone: {
type: 'onLeave', // change to 'onEnter' to test death on enter
source: rect
}
});
const graphics = this.add.graphics();
graphics.lineStyle(1, 0x00ff00, 1);
graphics.strokeRectShape(rect);
emitter.startFollow(this.followObj);
}
update() {
this.followObj.setPosition(this.input.activePointer.x, this.input.activePointer.y);
}
}
The particles will correctly die if they enter the onEnter
death zone or leave the onLeave
death zone, but moving the mouse in and out of the rect will sometimes cause the particle system to stop spawning completely and/or cause particles to seemingly spawn from other positions (either inside or outside of the rect).
If you switch to v3.80.1 in this example, the death zones work correctly.