Animation Bug??

Why does the square lose its local x once the animation has finished. I would expect the green square to keep going touching the red line not jump into the global x value

Is there something im going wrong?

local rectangle = display.newRect( 21, 194, 60, 40 )
rectangle:setFillColor( 100, 255, 100, 128 )
rectangle:setReferencePoint(display.TopLeftReferencePoint)
rectangle.direction = 1

local outline = display.newRect( 21,21,278,213 )
outline.strokeWidth = 1
outline:setStrokeColor( 255, 0, 0 )

– Add objects into group
interfaceGroup = display.newGroup()
interfaceGroup:insert( rectangle)
interfaceGroup:insert( outline )
interfaceGroup:translate( 0, 0)
interfaceGroup.xReference = 160
interfaceGroup.yReference = 160

masterGroup = display.newGroup()
masterGroup:insert( interfaceGroup )
masterGroup:translate( 0, 0 )
masterGroup.xReference = 160
masterGroup.yReference = 240
masterGroup.rotation = 0

– Setup tween
local params = { time=1000, rotation=90 }
transition.to( masterGroup, params )
function testfun()
if rectangle.direction == 1 then
rectangle.x = rectangle.x + rectangle.direction
if rectangle.x > 239 then
rectangle.direction = -1
end
else
rectangle.x = rectangle.x + rectangle.direction
if rectangle.x < 21 then
rectangle.direction = 1
end
end
–print(rectangle.x)
end
Runtime:addEventListener(“enterFrame”, testfun); [import]uid: 5354 topic_id: 666 reply_id: 300666[/import]

This is a known bug (discovered after 1.1) relating to internal coordinate systems of rotated groups.

It’s fixed in all versions of Corona starting with the current beta, which also adds iPad support. [import]uid: 3007 topic_id: 666 reply_id: 1333[/import]