Scale rectangle and keep top-left reference point?

I cannot sort out how to scale an object and keep its reference point at the top-left. It always resets to the center.

local trainingRect = display.newRect(0, 0, 1, 1)  
trainingRect:setReferencePoint(display.TopLeftReferencePoint)  
trainingRect:setFillColor(255, 0, 0, 50);  
  
trainingRect.tween = tnt:newTransition(trainingRect, { time=2000, height=150, width=75, transition=easingx.easeOut });  

I tried passing xReference/yReference as params but that made no difference. How can I do this? [import]uid: 70996 topic_id: 18683 reply_id: 318683[/import]

If it’s just the effect you’re going for try running this code;

[lua]local trainingRect = display.newRect(0, 0, 1, 1)
trainingRect:setReferencePoint(display.TopLeftReferencePoint)
trainingRect:setFillColor(255, 0, 0, 50);

transition.to(trainingRect, { time=2000, height=150, width=75, x=trainingRect.x+37, y=trainingRect.y+75})[/lua]

Peach :slight_smile: [import]uid: 52491 topic_id: 18683 reply_id: 71846[/import]

Thanks! That certainly gets the desired effect.

Is it expected behavior that setReferencePoint gets lost during transitions? Can I just not rely on setReferencePoint for animated objects? [import]uid: 70996 topic_id: 18683 reply_id: 72079[/import]

Not a problem.

I’ve had some trouble finding the relevant docs but yes I believe that during scaling at least the reference point will always revert to the center.

Peach :slight_smile: [import]uid: 52491 topic_id: 18683 reply_id: 72137[/import]