I told you… numChildren is a count of objects in the group
You index the group like you do table
local group = display.newGroup() print( group.numChildren ) display.newCircle( group, 10, 10, 10 ) print( group.numChildren ) -- Use transition to move the circle transition.to( group[1], { x = 200 } )
that comparison was just to elaborate, not the method you would use to find the last object.
I have the STRONG feeling you did not don’t think you read the docs I linked.
Try running this code to understand what I mean and how this works:
local group = display.newGroup() print("---- objects in 'group' == " .. tostring( group.numChildren ) ) local rect1 = display.newRect(group, display.contentCenterX, display.contentCenterY, 60,120) rect1.coins = 1 print("---- objects in 'group' == " .. tostring( group.numChildren ) ) local rect2 = display.newRect(group, display.contentCenterX, display.contentCenterY, 60,120) rect2.coins = 1 print("---- objects in 'group' == " .. tostring( group.numChildren ) ) local rect3 = display.newRect(group, display.contentCenterX, display.contentCenterY, 60,120) rect3.coins = 1 print("---- objects in 'group' == " .. tostring( group.numChildren ) ) local rect4 = display.newRect(group, display.contentCenterX, display.contentCenterY, 60,120) rect4.coins = 10 -- Hint! This will print: -- objects in 'group' == 4 print("---- objects in 'group' == " .. tostring( group.numChildren ) ) --To prove that 'rect4' is the last object do this: print( "Num coins: ", rect4.coins ) print( "Num coins: ", group[4].coins ) print( "Num coins: ", group[group.numChildren].coins )