Jump to content

Emitter particles following parent


jamessimo
 Share

Recommended Posts

Hey guys, I have 2 questions. 

1. Why can't a particle emitter follow a sprite using trackSprite?  

emitter.trackSprite(player, 48, 24); 

2. Currently my emitter follows the parent (player) by setting the emitters position on every step as mentioned here http://www.html5gamedevs.com/topic/5549-anchor-emitter-to-sprite/
The problem is that all the particles follows my sprite after it is emitted. I have attached the exact code I used below.  I don't want the emitted to share their local coordinates with the emitter after it has been fired. 

//Called every time my character shoots a weapon. 
emitter.position.x = player.position.x;
emitter.position.y = player.position.y;
emitter.start(true, 1000, 500, 1, true);

 

Link to comment
Share on other sites

It could, but emitters don't have that function. I'm pretty sure you could get the functionality you want by making the emitter a child of the player: "player.addChild(emitter);" Then it's positioned relative to the player, so you could add it at (0,0) and forget about it.

That said, if this emitter is for bullets you should check out the Phaser.Weapon plugin built-in to Phaser. It handles *a lot* of this stuff for you. But if you're asking about "trackSprite" you probably already looked at Weapon, so... ( =

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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