Groups inside localGroup

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?

For example:

I have two clouds: cloud1 & cloud2

Both are in the display group “clouds”

I insert “clouds” into localGroup…

Is that enough?

or do I have to individually…

localGroup:insert(cloud1)
localGroup:insert(cloud2)

Thanks for the help, [import]uid: 10361 topic_id: 8571 reply_id: 308571[/import]

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]

Awesome. Thanks for the response. It appears that’s correct.

I love this Director class. :slight_smile: [import]uid: 10361 topic_id: 8571 reply_id: 30879[/import]