How do you reset object.xReference after rotation without the object jumping? Sample code inside

Hi,
I use the object.xReference attribute to rotate (transition.to) an object about an axis other than the default Reference point. My problem is, that whenever I reset the object.xReference property or change it to a different value for another transition.to the object jumps to a point where it would have ended up if I hadn't set the object.xReference for the previous step.

The animation consists of many steps which are defined in a table imported from a json file. That means I cannot hard-code the reset of the object position after I change the xReference attribute.

I tried to programmatically calculate the x and y distance the object would have to be moved to retain it's position, but since the rotation can start at any angle and end at any angle even a simple sin/cos calculation gets a bit crazy. Also, the object 'jerks' if I try to reset it after changing the x/y reference values.

Is there a way to reset the reference points without the object moving?

Thanks for your help.

Best, Oliver

Here is a very simplified sample of what is happening:

1
2
3
4
5
6
7
8
9
10
11
12
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 ()
rect.yReference = 50
end
 
transition.to( rect, { time=1000, delay=0, rotation=90, onComplete=jump } )

Hello, Oliver
Probably, I am having the same or similar problem. I described it here:

http://developer.anscamobile.com/forum/2011/09/08/problem-changing-reference-point-rotating-object

In my test case the problem can be solved if update objects .x and .y after changing reference point but before rotating it, but in more complex cases unpredictable bugs happen...
Sent a bug report. My decision whether to purchase corona or not is depending on how fast it will be fixed...

Regards, Alex

views:1618 update:2011/9/25 12:40:18
corona forums © 2003-2011