How to: ROTATE FIRST, set REFERENCE POINT SECOND?

Hi,

I need to rotate an object from it center and right after that change it’s reference point for constant scaling function.

The problem is that changing the reference point afects the rotation no matter the order you call the functions. See example where the object is roteted from the new reference point altough “rotate” was called before.

local rect=display.newRect(300,300,50,50)  
rect:rotate(45)  
rect.xReference=display.contentCenterX  
rect.yReference=display.contentCenterY  

How can I solve this situation?

Thanks! [import]uid: 76413 topic_id: 23868 reply_id: 323868[/import]

Er…assuming those reference points work (probably?) have you tried maybe function nesting?

[code]
local function refpoint()
rect.xReference=display.contentCenterX
rect.yReference=display.contentCenterY
end

local rect = wharves
rect:rotate(45)
timer.perfomWithDelay(100, refpoint)[/code]

That way you enforce even a minor time delay which forces the rotation to happen first. (Maybe this even works if you simply call the function after the rotate…I’m not sure.) [import]uid: 41884 topic_id: 23868 reply_id: 96159[/import]

Yes, this works, but for my case any delay is not acceptable because the new reference point is used immediately for scaling

Is it possible to make the order of the opperations apply like that? I think is logical.

Thanks [import]uid: 76413 topic_id: 23868 reply_id: 96276[/import]

Ha! I had this issue just the other day and could not figure it out for the life of me. What an odd behavior… is this a view at the inner workings of Corona’s communication with box2d…

[import]uid: 21331 topic_id: 23868 reply_id: 96293[/import]

Well, it’s more that Corona is built to execute those things but not actually update inbetween. Which is why I wondered if calling the function might buy enough process time to update the screen before changing the reference point? [import]uid: 41884 topic_id: 23868 reply_id: 96308[/import]

It doesn’t
I already tryed
What a pitty :frowning: [import]uid: 76413 topic_id: 23868 reply_id: 96441[/import]

Considered trying a really minimal timer, like 5 or something? Might be small enough to enforce the change but not be noticeable. [import]uid: 41884 topic_id: 23868 reply_id: 96478[/import]