What is the purpose of setReferencePoint?

I am using Corona SDK Mobile Game Book

Pg 104

playBtn = display.newImage(“playbtn.png”)
playBtn:setReferencePoint(display.CenterReferencePoint)
playBtn.x = _W; playBtn.y = _H + 50
playBtn.name = “playbutton”

No information about the setReferencePoint near that page, so I went back to page 66 where they talk about object:setReferencePoint and all I could find is where it says “Sets the reference point”, I almost want to say “Duh” but don’t want to be mean. But, it tells me NOTHING about the purpose. Ok, so you set a reference point. So what? Why? What does it do?

Then I found http://developer.coronalabs.com/reference/index/objectsetreferencepoint and I got the idea that in that example - it is used to center aline text. “A picture would have been nice”

But, then I looked at this code and it was an object. So, I thought maybe it centered alined to the screen or something. So, I took it out. Nothing changed. The words didn’t change and the button didn’t change. So, I saw no point in having that command. So, is there a purpose or is this one of those times when the author is just so used to putting code in that they put it in but it is not needed?
Just curious or can someone explain the purpose here.

Also, if not used for text, what is the purpose? Again, for text, I got the opinion it was for center aligning the text, I hope I am right.

Thanks!

[import]uid: 159663 topic_id: 28278 reply_id: 328278[/import]

You are correct RE use with text, that’s why most people would use it in that case.

You can change the reference point if you don’t want to position something by its center. For example you have a circle on the screen. You want to add a square and position it so that the top left corner is in the center of the circle.

You could do this mathematically, of course, but it is easier to simply give the square a top left reference point and then say square.x, square.y = circle.x, circle.y.

Does that make sense?

Peach :slight_smile: [import]uid: 52491 topic_id: 28278 reply_id: 114294[/import]