object.xReference - bug or feature?

In my first Corona iPhone app I move objects around the screen with transition.to animations. One of the key requirements is to rotate objects around an axis outside of the object. Sounds like a great application for the xReference attribute, right?

Well it works really well until I change the xReference value for a later transition. This makes the object jump to a position which it would have ended up if I had done the previous rotation without to xReference set correctly.

Is this a bug or a feature?

Thanks, Oliver

Sample code:
[lua]local rect = display.newRect(100, 200, 80, 20)
rect.strokeWidth = 2
rect:setFillColor(140, 140, 140)
rect:setStrokeColor(180, 180, 180)

rect.yReference = -50

jump = function ()
rectw = rect.width
recth = rect.height
rectx = rect.x
recty = rect.y
rectr = rect.rotation
display.remove( rect )
local rect = display.newRect((rectx - 80 / 2), (recty - 20 / 2), 80, 20)
rect.strokeWidth = 2
rect:setFillColor(140, 140, 140)
rect:setStrokeColor(180, 180, 180)
rect.rotation = rectr

rect.yReference = 50

local title2 = display.newText( rectx, 200, 40, “GurmukhiMN-Bold”, 20 )
local title2 = display.newText( recty, 200, 80, “GurmukhiMN-Bold”, 20 )
local title2 = display.newText( rectr, 200, 120, “GurmukhiMN-Bold”, 20 )

local title2 = display.newText( rect.x, 100, 40, “GurmukhiMN-Bold”, 20 )
local title2 = display.newText( rect.y, 100, 80, “GurmukhiMN-Bold”, 20 )
local title2 = display.newText( rect.rotation, 100, 120, “GurmukhiMN-Bold”, 20 )
end

transition.to( rect, { time=2000, delay=100, rotation=90, onComplete=jump } )[/lua] [import]uid: 69642 topic_id: 14451 reply_id: 314451[/import]

This video should help:

http://www.youtube.com/watch?v=sKAWaLLG9vQ

Regards,
Jordan Schuetz
Ninja Pig Studios [import]uid: 29181 topic_id: 14451 reply_id: 53482[/import]

Thanks Jordan, I watched that video before trying to use the xReference and it was very useful to understand the concept.

However…
in this video the xReference values are never changed during the animation.

If you run the code I posted you can see the bug I described. According to the documentation for the xReference attribute the x/y position should not change when the xReference value is changed, but it does.

In the example I rotate an object about an axis outside the object by setting the xReference attribute. At the end of the animation I change the xReference value and the object jumps to a different location. Bug or feature?

Best, Oliver

Sorry I just saw that I use the yReference in the sample - same effect though. [import]uid: 69642 topic_id: 14451 reply_id: 53596[/import]