Jump to content

Trying to understand emitters (reset/restart/revive...)


Recommended Posts

Hi there, so I have this basic question with Phaser and emitters... I have an emitter "shooting" 5 items every X seconds. Imagine a classic shot´em up, a final boss... he´s shooting at you every X seconds.


I create my emitter this way:

this.myEmitter= this.game.add.emitter(posX, posY, 5);

So I have my emitter shooting 5 bullets and I have this inside a setInterval (I just realized I should change this) so it´s shooting every X seconds.


What I wanna do is

  • If the bullets don´t hit you, "reset" the emitter. Nothing happens but the emitter is ready to fire again, just 5 bullets.
  • If the bullets hit you (something with your spaceship obviously) and "kill" the emitter to "revive" it later, kind of. The idea is "ok, the bullet hit you, -- you life and the emitter should be ready to start again.


I´m having different problems, the weirdest one is that I have the limit to 5 particles and the number of them is increasin, 5, 10, 15... If I kill the emitter, the second time is not shooting... 


I´m pretty sure this is basic stuff, but I´m having those little issues so the code is not working properly. Can anyone point me to a tutorial or a brief explanation about how to do this, please?


Thanks in advance.


Sorry, this should be in the regular forums, no in the Phaser 3 one (I reported myself)

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...