I have a question about removing display objects…
I was under the impression a person should remove the object from the display and then specifically set it equal to nil so that it will get cleaned up.
Why does the first version leave an empty table I can reference? (display.remove(self) seems to remove all table information but self = nil doesn’t seem to remove the table it’s self)
[lua]
–this leaves the dwarfSprite table that I can reference but find no table values in (breaks my set up when I later check to see that dwarfSprite ~= nil but then it has no data in it:
function dwarfSprite:destroy()
display.remove(self) --these weren’t working but if I specify the object then it does… what?!
self = nil
end
–this actually removes the dwarfSprite table so that I am unable to reference it at a later time (desired - fails my dwarfSprite ~= nil check)
function dwarfSprite:destroy()
display.remove(dwarfSprite)
dwarfSprite = nil
end
[/lua]