Jump to content

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?




Link to comment
Share on other sites

Link to comment
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.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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