This might be a noob question but I’m just curious and want to do things right.
Will objects still get cleaned up if you have them inside a group that got inserted into localGroup? Or do you have to manually insert every object singularly into localGroup?
I’m 90% sure that it cleans all groups within groups automatically. The director class does it when you changeScene(). Here’s the code from director.lua that gives me that impression.
[lua]------------------------------------------------------------------------
– CLEAN GROUP
local function cleanGroups ( curGroup, level )
if curGroup.numChildren then
while curGroup.numChildren > 0 do
cleanGroups ( curGroup[curGroup.numChildren], level+1 )
end
if level > 0 then
curGroup:removeSelf()
end
else
curGroup:removeSelf()
curGroup = nil
return true
end
end[/lua]
It looks like it’s using recursion and diving in deeper and deeper until it runs out of layers of groups. [import]uid: 10211 topic_id: 8571 reply_id: 30847[/import]