How To Get The Reference Point Of A Object?

Hi.

 

Is there way to get the reference point of a object (e.g, display.CenterReferencePoint, …)?

 

I want that info because sometimes I change the reference point of a object to get its central position but then I want to set the reference point again to the original one.

 

Thanks,

 

 

Renato

 

 

 

 

I don’t see anything like that in the API docs. Maybe you could save the original ref point as a property of the object, that way it would be easy to reset.

 

So when you first create the display object, save the reference point:

 

[lua]

obj:setReferencePoint(display.TopLeftReferencePoint)

obj.origRefPt = display.TopLeftReferencePoint

[/lua]

 

Now when you need to set it back to the original after changing, just do:

 

[lua]obj:setReferencePoint(obj.origRefPt)[/lua]

 

I think that should work okay.

 

 Jay

Yes, i was looking for something intrinsic implemented but it appears that I would have to do that way. I just need to have the discipline that when I change reference point for good that I update that property as well.

 

Thanks for the suggestion.

I don’t see anything like that in the API docs. Maybe you could save the original ref point as a property of the object, that way it would be easy to reset.

 

So when you first create the display object, save the reference point:

 

[lua]

obj:setReferencePoint(display.TopLeftReferencePoint)

obj.origRefPt = display.TopLeftReferencePoint

[/lua]

 

Now when you need to set it back to the original after changing, just do:

 

[lua]obj:setReferencePoint(obj.origRefPt)[/lua]

 

I think that should work okay.

 

 Jay

Yes, i was looking for something intrinsic implemented but it appears that I would have to do that way. I just need to have the discipline that when I change reference point for good that I update that property as well.

 

Thanks for the suggestion.