In terms of positioning display objects you are placing into a display group, should one be able to trust the “width”/“height” for a display group? Are there gottchas here which imply you should never rely on these?
Why for example does this code not work. I’m expecting the red circle to be inside the square in the top right, however this isn’t what I get:
display.setStatusBar( display.HiddenStatusBar ) local outerGroup = display.newGroup() local myRectangle = display.newRect(outerGroup,0, 0, 200,200) myRectangle.strokeWidth = 3 myRectangle:setFillColor(140, 140, 140, 0) myRectangle:setStrokeColor(200,00,0) outerGroup:setReferencePoint(display.TopLeftReferencePoint) outerGroup.x, outerGroup.y = 20,20 local topRightCircle = display.newCircle(outerGroup, 0, 0, 30 ) topRightCircle:setFillColor(128,128,128, 0) topRightCircle.strokeWidth = 5 topRightCircle:setStrokeColor(0,200,0) -- green topRightCircle:setReferencePoint(display.TopRightReferencePoint) topRightCircle.x, topRightCircle.y = outerGroup.width, 0 -- \<== X setting using outerGroup.width doesn't work
Gives: