Closed nickryall closed 8 years ago
I can't replicate this. The example below works fine. What is different about your version to throw this?
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
var emitter;
function preload() {
game.load.image('diamond', 'assets/sprites/diamond.png');
}
function create() {
game.physics.startSystem(Phaser.Physics.ARCADE);
game.stage.backgroundColor = 0x337799;
emitter = game.add.emitter(0, 0, 100);
emitter.makeParticles('diamond');
emitter.gravity = 200;
game.input.onDown.addOnce(particleBurst, this);
}
function particleBurst(pointer) {
emitter.x = pointer.x;
emitter.y = pointer.y;
emitter.start(true, 4000, null, 10);
// And 2 seconds later we'll destroy the emitter
game.time.events.add(2000, destroyEmitter, this);
}
function destroyEmitter() {
emitter.destroy();
}
Sorry I totally missed your reply to this. I will look into it further and report back.
This was indeed a bug in my own code. Long story short, I was calling destroy() on the emitter instance twice in quick succession. So the 2nd time around as expected this.game = null.
Sorry about that. Thanks for taking the time to take a look.
When calling destroy() on an Emitter, I get the following error on this line:
93476: this.game.particles.remove(this);
Uncaught TypeError: Cannot read property 'particles' of null
I'm guessing the reference to this.game is lost when creating a new emitter.