bobonthenet Posted April 5, 2018 Share Posted April 5, 2018 Should it be possible to create emitters in a loop and then add them to a group? I'm trying to use particle emitters as explosions and I might need to fire off multiple at a time. I figured I would use basically the same strategy used with bullets. Maybe there is a better strategy? this.explosions = this.add.group(); let particles; let emitter; for(let i=0; i<3; i++) { particles = this.add.particles('spark'); emitter = particles.createEmitter(); emitter.setSpeed(200); emitter.setBlendMode(Phaser.BlendModes.ADD); emitter.on = false; this.explosions.add(emitter); //this line causes an error. } Link to comment Share on other sites More sharing options...
samme Posted April 6, 2018 Share Posted April 6, 2018 17 hours ago, bobonthenet said: I'm trying to use particle emitters as explosions and I might need to fire off multiple at a time. I think you can use just one emitter for that. Link to comment Share on other sites More sharing options...
bobonthenet Posted April 9, 2018 Author Share Posted April 9, 2018 It looks as if when I already have an explosion in process and then a second is fired, then the second explosion would not be complete. It looks as if the first explosion has taken up a portion of the duration of the second explosion. Here is the code I am using for my explosions, maybe this isn't the best strategy. .... create() { //Particles and emitter are created in the create method. const particles = this.add.particles('spark'); this.emitter = particles.createEmitter(); this.emitter.setSpeed(200); this.emitter.setBlendMode(Phaser.BlendModes.ADD); this.emitter.on = false; } ... //This explosion method is called inside the colliding sprites death method. explosion(x, y) { this.emitter.setPosition(x, y); this.emitter.on = true; this.time.delayedCall(1500, function(){ this.emitter.on = false; }, [], this); } P.S. @samme I love brunch now! Thanks for sharing your starter project. Link to comment Share on other sites More sharing options...
Recommended Posts