Is there any sample code that demonstrates the removal of objects from a table?
In this case, every frame I am checking for any objects that have fallen off the screen. If they have, I want to remove them from memory.
for i,val in ipairs(particles) do
if(val.y \> 320) then
particles[i]:removeSelf();
particles[i] = nil;
end
end
This works only on the first particle that falls off the screen, then the for loop no longer gets entered. This seems like a common task but I can’t find any examples of best practices. [import]uid: 52127 topic_id: 10714 reply_id: 310714[/import]
[import]uid: 3826 topic_id: 10714 reply_id: 39002[/import]