button positions

From what origin are button positions actually calculated? I have an app I’m working on. I never define any screen to be less than full screen – actually, I don’t define any screen at all.

Yet when I create a button and use ‘button.x = 198’, I get a button that actually starts within a pixel or so of x=160. What I’ve found is that for some reason I have to add about one half the size of my button on to the actual x position I need.

Why?

Sean. [import]uid: 4993 topic_id: 553 reply_id: 300553[/import]

By default you set the position of the center of the object. So your guess of having to add half the size was correct.

However, you can change the reference point, as it is called, using the function:

button:setReferencePoint(display.TopLeftReferencePoint)
button.x = 198 – the button will now start at 198

See the API reference for more information on setReferencePoint

Arjan
[import]uid: 4824 topic_id: 553 reply_id: 1083[/import]