Type Number Object GroupObject Library display.* Revision Release 2024.3703 Keywords anchorChildren, anchor See also Group Programming (guide)
By default, display groups do not respect anchor points. However, you can achieve anchor behavior on a display group by setting this property to true
.
Setting this property does not force an immediate update of the group, although other display properties will do so. This was assumed to be an oversight and fixed along with some sprite trimming issues. To opt-in to these fixes, set the default of "isImageSheetFrameTrimCorrected"
to true
.
local myGroup = display.newGroup() local myBox = display.newRect( 100, 100, 80, 80 ) myBox:setFillColor( 1, 0, 0, 0.8 ) myGroup:insert( myBox ) myGroup.x = 50 myGroup.y = 50 --Add a smaller blue box local blueBox = display.newRect( 50, 50, 50, 50 ) blueBox:setFillColor( 0, 0, 1, 0.8 ) myGroup:insert( blueBox ) myGroup.anchorChildren = true