in my game I have some code to clean up all the display objects that I don’t need anymore when switching from game.lua to over.lua
I get a bunch of warnings in the terminal and I am wandering how to fix this.
WARNING: Attempting to set property(9) with nil
WARNING: Attempting to set property(8) with nil
WARNING: Attempting to set property(7) with nil
WARNING: Attempting to set property(6) with nil
WARNING: Attempting to set property(5) with nil
WARNING: Attempting to set property(4) with nil
WARNING: Attempting to set property(3) with nil
WARNING: Attempting to set property(2) with nil
WARNING: Attempting to set property(1) with nil
code looks something like this
[lua]local function gameOverCleanup( )
Runtime:removeEventListener(“postCollision”, onCollision)
Runtime:removeEventListener( “enterFrame”, onEnter )
background:removeSelf()
background = nil
player:removeSelf()
player = nil
dpad:removeSelf()
dpad = nil
dpad_light:removeSelf()
dpad_light = nil
bn_thrust:removeSelf()
bn_thrust = nil
bn_fire:removeSelf()
bn_fire = nil
score_text:removeSelf()
score_text = nil
while missles.numChildren > 0 do
missles[missles.numChildren]:removeSelf()
missles[missles.numChildren] = nil
end
missles = nil
while astroid_group.numChildren > 0 do
astroid_group[astroid_group.numChildren]:removeSelf()
astroid_group[astroid_group.numChildren] = nil
end
astroid_group = nil
lives_group = nil
Runtime:addEventListener(“enterFrame”, gameEnterFrameHandler)
changeScreen(“over_screen”)
callUnload = true
end
function unloadMe( )
collectgarbage(“collect”)
end[/lua] [import]uid: 6636 topic_id: 3538 reply_id: 303538[/import]