Sign in to follow this  

remove an item from a group

Recommended Posts


I have a group of items that their y position in increased by 1 during update

I want to remove every item the its y is bigger than 600.

I'm using kill()


but this only kill the item's spot but the group has the same length.

As the group size is increased every x seconds, the size of the group will get really big over time

How can I  kill/remove the item and keep the size of the group to the real number of items?




Share this post

Link to post
Share on other sites

Share this post

Link to post
Share on other sites

You need to `destroy` or `remove` item  to remove it from group. 

`kill` only sets `alive`, `exists` and `visible` properties to false. It won't remove it from group.

Since you're creating and destroying items frequently. Better approach would be to do object pooling. When item goes below 500, you `kill` it and when you want new item you find in the group for items which `alive` is set to false. and `revive` that item and change positions of that item.

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.

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.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.