object.numChildren

Type Number
Object GroupObject
Library display.*
Revision Release 2022.3683
Keywords group children, child count, group count
See also Group Programming (guide)

Overview

Retrieve the number of children in a group. You access the children by integer (whole number) index.

Example

local group = display.newGroup()
group:insert( rect1 ) -- assume rect1 is an existing display object
group:insert( rect2 ) -- assume rect2 is an existing display object

for i=1,group.numChildren do
    local child = group[i]
    local description = (child.isVisible and "visible") or "not visible"
    print( "child["..i.."] is " .. description )
end