I am unable to set anchor points for containers …
I have a group, which has lots of elements(around 30)
When I try to insert the group inside a container (whose width and height are the same as the group’s width and height), the container clips the group at its Top Left.
The Container docs state
By default, the clip bounds are centered about the container's origin. You can adjust the anchor to control this.
So I tried changing the anchor points to .5, .5
Sill doesn’t work. Same problem…
What am I doing wrong here?
Here is my code
[lua]
–this is the group where the circles are inserted
local localGroup = display.newGroup()
–create 27 circles in 3 rows here
local rad = 10
local circleW,circleH = 2*rad,2*rad
local xSpace,ySpace = 10,10
local xStart,yStart = 0,0
for i=1,27 do
local row,col = getRowColumnFromMatrixIndex(i,3,9)
local l = xStart + (circleW+xSpace)*(col-1)
local t = yStart + (circleH+ySpace)*(row-1)
local x,y = l+circleW/2, t+circleH/2
local circle = display.newCircle(localGroup,x,y,rad)
end
–create container and insert group
local containerW,containerH = localGroup.width,localGroup.height
local container = display.newContainer(containerW,containerH)
container:translate(40,140)
container:insert(localGroup)
container.anchorChildren = false
container.anchorX = 0
container.anchorY = 0
[/lua]