Hi!
I have created a table (called myRectangle) that contains 9 rectangles (created with display.newRect). I want to remove a random rectangle until all the rectangles has been removed.
This is what I got so far:
local t = {} function t:timer( event ) local topRand = 10 - event.count local randNumber = (math.random (1, topRand)) table.remove(myRectangle, randNumber) end timer.performWithDelay( 1000, t, 9 )
This works for removing rectangles from the table, but I also want to remove the display object so the rectangle won’t be visible anymore. I have tried to add this both before and after removing from the table:
myRectangle[randNumber]:removeSelf() myRectangle[randNumber] = nil
But this does not remove the same object from the table as the table.remove does.
Does anyone have any ideas for how to remove my rectangles?
I appreciate any help 