how do list all created display groups?

Is there a way to list all display groups created in a scene and what they contain?

I’m trying to re-organize my code and it would be handy to see if I left out anything. Then I’m thinking of using DisplayManagerto tidy up my display objects.

I’m using the inspect plugin but it doesn’t show anything interesting in the case of display objects.

something like this:

function DisplayDump(rootgroup) local function dump(group,indent) if (group and group.numChildren) then print(indent.."\<group\> "..tostring(group)) for i = 1, group.numChildren do local child = group[i] if (child.numChildren) then dump(child, indent.." ") else print(indent.." \<object\> "..tostring(child)) end end end end dump(rootgroup,"") end DisplayDump(display.getCurrentStage())

if you’re meticulous about adding a .tag or .name property to everything then you could include that for nicer reporting

for scene-specific use, just pass in scene.view instead of the whole stage

I tried your code for one of my scene and I get 570 objects and 20 groups (which sounds enormous!).

I’ve modified this line:

print(indent.." \<object\> "..tostring(child))

and replaced it by:

print(indent.."&nbsp; \<object\> "..inspect(child))

So I can get more details about the object, e.g:

\<object\> { \_class = \<1\>{ \_\_index = \<table 1\>, addEventListener = \<function 1\>, removeEventListener = \<function 2\>, \<metatable\> = \<2\>{ \_\_index = \<table 2\>, \_super = \<3\>{ \_\_index = \<table 3\>, \_indexForType = { function = "\_functionListeners", table = "\_tableListeners" }, \_super = \<4\>{ \_\_index = \<table 4\>, new = \<function 3\>, newClass = \<function 4\> }, addEventListener = \<function 5\>, didRemoveListener = \<function 6\>, dispatchEvent = \<function 7\>, getOrCreateTable = \<function 8\>, hasEventListener = \<function 9\>, removeEventListener = \<function 10\>, respondsToEvent = \<function 11\>, \<metatable\> = \<table 4\> }, addEventListener = \<function 12\>, removeEventListener = \<function 13\>, \<metatable\> = \<table 3\> } }, \_isLabel = true, \_labelColor = { default = { 0.08, 0.49, 0.98, 1 }, over = { 0.08, 0.49, 0.98, 1 } }, \_proxy = \<userdata 1\>, \<metatable\> = { \_\_index = \<function 14\>, \_\_newindex = \<function 15\> }

But from this, is there a way to get the actual name (“myListView4”, “myYellowRect”) and the object type (“tableView”, newRect) ?

no, you can’t retrieve the name of the variable(s) that the object may happen to be stored in.

that’s what you’d use a .tag or .name field for

local myGroup = display.newGroup() myGroup.tag = "myGroup" local myRect = display.newRect(.. myRect.tag = "myRect"

now print those tags