Jump to content

Anchor emitter to sprite


Stonekeeper
 Share

Recommended Posts

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

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

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.rotation

But why would you do it like this? Use the manual sync mentioned above instead!

Link to comment
Share on other sites

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

  • 3 years later...

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

 Share

  • Recently Browsing   0 members

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