I dont know about arrays.
I try to remove the objects from the timerperfomrwith delay ,when There are 10 objects, I remove .
but when there are about more than 10 it only removes ten and leaves the rest.
i f I have 30 objects It doesnt remove all the objects
[lua]
rectangles = {};
function rectanguloSpawn()
for i = 1, 10 do
i=i+1
rectangles[i] = display.newImageRect(“frog.png”,52,52);
rectangles[i].x=i*50
rectangles[i].y=65
physics.addBody(rectangles[i],“dynamic”)
end
end
timer.performWithDelay(1000, rectanguloSpawn, 0)
function remove()
for i=1,10 do
i=i+1
physics.removeBody(rectangles[i])
display.remove(rectangles[i])
rectangles[i] =nil
end
local buttonRemove=display.newImageRect(“removeButton.png”, 50, 50)
buttonRemove.x=45
buttonRemove.y=100
buttonRemove:addEventListener(“tap”, remove)
[/lua]