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 [import]uid: 69642 topic_id: 14175 reply_id: 314175[/import]

Here is a very simplified sample of what is happening:

[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 ()
rect.yReference = 50
end

transition.to( rect, { time=1000, delay=0, rotation=90, onComplete=jump } )[/lua]

How I interpreted the docu for object.yReference the rectangle should not move when the xReference value is changed. Is my logic off?

Thanks for your thoughts.

  • Oliver [import]uid: 69642 topic_id: 14175 reply_id: 52186[/import]

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 [import]uid: 66525 topic_id: 14175 reply_id: 55810[/import]

@Alex, thanks for reporting.
Doesn’t seem to be high priority. Maybe it is considered a ‘feature’ after all.
I was able to work around it in my ‘TangoSteps’ app, but it isn’t pretty…
Gotta say though, I love Corona anyway. Could not have done the app without it.

  • Oliver [import]uid: 69642 topic_id: 14175 reply_id: 57106[/import]