Instead of removing a table directly, I'm trying to remove it via a reference to.
Here's a demonstration of what I am trying to do:
local object1 = display.newCircle( 120, 60, 40 ) local object2 = display.newCircle( 220, 60, 30 ) object2.reference = object1 print( object1 ) print( object2.reference ) display.remove( object2.reference ) object2.reference = nil print( object1 ) print( object2.reference )
Now, as expected, if I adjust the position of either object1 or object2.reference, both tables are updated and the display object moves on the screen. Also, if I print object1 or object2.reference, the console outputs the same table, as expected.
However, if I remove the display object and set the table to nil via either object1 or object2.reference, then the display object is removed, but the table that was not explicitly set to nil remains with all of its information.
Any suggestions on how I could get rid of both using a method similar to this?