alvatar

Detaching Sprite from Group so tweens don't affect it

Recommended Posts

Hi!

 

I'm trying to figure out how to detach a sprite from a Group.

 

Currently you add it with the group as a two-step process:

1) Create the Sprite

2) Add it to the group: group.add(sprite)

 

But if I want to detach it from the group, so I can handle it individually, I have no other option than "destroy", which removes the Sprite.

Setting the parent to null doesn't work either.

The objective is that when a specific condition is met, the tween that is applied to all elements in the group as a whole doesn't apply to this particular sprite.

 

Thank you!

 

 

Share this post


Link to post
Share on other sites

Move it to another Group:

group.remove(sprite);group.add(sprite);

Remember that World is a Group. So you can do world.add(sprite) quite happily, which will keep it on the display list and rendering.

 

Removing a child from a Group does not destroy or kill it, but it WILL stop rendering if you don't add it back onto the display list somewhere.

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

  • Recently Browsing   0 members

    No registered users viewing this page.