Hi,
I have noticed a strange behaviour from the function setReferencePoint to a display object. I’m not sure it is a bug or there is some logical reason for that.
It happens the following:
I display a rectangle.
add it to a group
Rotate the group
move the rectangle.
The rectangle is moved in the x direction relative to the group rotation
group position is not affected
local group=display.newGroup()
local rect=display.newRect(0,0,200,200)
group:insert(rect,true)
group.x, group.y=display.contentWidth/2, display.contentHeight/2
group:setReferencePoint(display.CenterReferencePoint)
print("x, y: "..group.x.." "..group.y)
group:rotate(45)
rect.x=rect.x+100
--group:setReferencePoint(display.CenterReferencePoint)
print("x, y: "..group.x.." "..group.y)
but if I reset the reference point of the group after moving the rectangle, then the rectangle is moved moved as if i had made the addition to the group, not the rectangle
local group=display.newGroup()
local rect=display.newRect(0,0,200,200)
group:insert(rect,true)
group.x, group.y=display.contentWidth/2, display.contentHeight/2
group:setReferencePoint(display.CenterReferencePoint)
print("x, y: "..group.x.." "..group.y)
group:rotate(45)
rect.x=rect.x+100
group:setReferencePoint(display.CenterReferencePoint)
print("x, y: "..group.x.." "..group.y)
If you test the two posted versions you will see the effect.
Is this a bug of the function setReferencePoint or there is a logic behind this behaviour?
Thanks!
Ernest.
[import]uid: 76413 topic_id: 21958 reply_id: 321958[/import]