So I want to do the following thing:
- Create some display objects and add them to a group
- Move them each frame (during a single global enterFrame event)
- Remove some of the display objects (the ones that are off screen) from the group
The following code won’t work (since an object was removed and numChildren has changed):
[lua]local myDisplayObj = nil
for i=1, myGroup.numChildren do
myDisplayObj = myGroup[i]
if myDisplayObj.x > 1000 then
myDisplayObj:removeSelf()
end
end[/lua]
Any suggestions on how to do it nice and clean? [import]uid: 9536 topic_id: 6365 reply_id: 306365[/import]