Stonekeeper Posted April 10, 2014 Share Posted April 10, 2014 On the webpage it talks about attaching an emitter to a sprite so that you can create a "jet". Is this done via groups? I've setup a player sprite and all my controls currently work on that. If creating a group is the answer, should a refactor be as simple as changing <sprite>.body to <group>.body? Thanks. Link to comment Share on other sites More sharing options...
codevinsky Posted April 10, 2014 Share Posted April 10, 2014 Check this out: Phaser: Attach Particle Emitter to a sprite [CodePen] The most important thing to take away is that you can add any game object to a sprite with: sprite.addChild(gameObject); Alexalten 1 Link to comment Share on other sites More sharing options...
Stonekeeper Posted April 10, 2014 Author Share Posted April 10, 2014 Perfect! Thank you so much.Seems obvious when you see the code. Stonekeeper 1 Link to comment Share on other sites More sharing options...
Stonekeeper Posted April 11, 2014 Author Share Posted April 11, 2014 Looks like the particles are also affected by the rotation of the parent object. Not really what I was looking for. If there is no way to detach the particle from the transformation pipeline then I may just have to calculate emitter position independently using cos/sin. Link to comment Share on other sites More sharing options...
george Posted April 11, 2014 Share Posted April 11, 2014 I would not add the emitter to a sprite with addChild. You can't really control if the emitter is going to render above or beneath the sprite texture. You should place a simple position syncing in your update loop.//This update function is provided by your current stateupdate: function(){ emitter.x = sprite.x emitter.y = sprite.y} That's it.By the way, you could also apply a counter rotation to the emitter in your sprite's update function. Something like this. This works as long as your sprite is not inside another object that is rotated itself. //inside your sprite updateemitter.rotation = -this.rotationBut why would you do it like this? Use the manual sync mentioned above instead! Link to comment Share on other sites More sharing options...
codevinsky Posted April 11, 2014 Share Posted April 11, 2014 george: A quick question:How would you determine the speed to set the particles so that they always fired "behind" the sprite, even after rotation? Link to comment Share on other sites More sharing options...
george Posted April 11, 2014 Share Posted April 11, 2014 Your are talking about the situation that the emitter is not a child of the sprite aren't you ? The emitter inherits from group. Every particles is a child of the emitter. As long as the emitter is behind the sprite all the particles are behind it too. The emitter itself is a display object and can be brought in the correct display order with a #swap, a #bringToTop call or whatever you can use to modify the order. Link to comment Share on other sites More sharing options...
rich Posted April 11, 2014 Share Posted April 11, 2014 If the Sci-Fly example (under tilemaps) you'll see how I attach an emitter to a sprite. Could work for this maybe. Link to comment Share on other sites More sharing options...
Hipe Posted January 22, 2018 Share Posted January 22, 2018 Hi, may I use this post by George ( //This update function is provided by your current stateupdate: function(){ emitter.x = sprite.x emitter.y = sprite.y} ) I have a group of missile and I need each missile be follow by my particles. Thanks a lot. Link to comment Share on other sites More sharing options...
samme Posted January 22, 2018 Share Posted January 22, 2018 Link to comment Share on other sites More sharing options...
Recommended Posts