jamessimo Posted January 13, 2017 Share Posted January 13, 2017 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 More sharing options...
drhayes Posted January 13, 2017 Share Posted January 13, 2017 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 More sharing options...
samme Posted January 13, 2017 Share Posted January 13, 2017 You want to use emitter.emitX = player.position.x; emitter.emitY = player.position.y; Link to comment Share on other sites More sharing options...
jamessimo Posted January 17, 2017 Author Share Posted January 17, 2017 Thanks guys, the emitX/Y thing worked, also had a weird bug where I scaled the particle emitter and it caused the position to be incorrect. I am using a weapon @drhayes, Just need a cartoony muzzle flash using particles Link to comment Share on other sites More sharing options...
Recommended Posts