Jump to content

Reuse Emitter, bug or bad use ?


Kiwi404
 Share

Recommended Posts

Hi,

Is there any method to reset an emitter properly to be reused ? because i reuse a set of emitters but sometimes when i reuse a previously used emitter it show quickly his last state (repartition of particules in their last coordinates) and then restart his animation, so i wonder if is it a bug or a bad use.

EDIT : It's a bad.

Code used to instanciate the emitters in the poolEmitter (extended Phaser.group) instance :

 em = game.add.emitter(10,16,30)
 // some emitter settings (minRotation, setXSpeed,makeParticles...)

em.kill()
this.add(em)
  

Code used in the poolEmitter instance to get a free (dead) emitter :

    let obj = this.getFirstDead(false)
    obj.revive()
    obj.x = x
    obj.y = y
    return obj

Code used for exploitation of the emitter :

 let em = poolEmitter.create(player.x ,player.y)
        em.explode(800,30)
        setTimeout(function(){
            em.kill()
            em.on = false
            em.visible = false
            /* em.forEach(function(p) {   // I try this to hide the particule manually to avoid to be showed in their last coord when reuse the emitter, but dont work
                p.alpha = 0
            })*/
        },900)

 

Thanks

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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