Sign in to follow this  
Kiwi404

Reuse Emitter, bug or bad use ?

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.