How can I center a display.newRetinaText?

How can I center a display.newRetinaText?

myText2 = display.newRetinaText( "You have one ball and you have to keep the ball high as many times as you can", 30, 70, 280, 220, native.systemFont, 22 ) myText2:setTextColor( 255, 0, 0 ) screenGroup:insert( myText2 ) [import]uid: 203192 topic_id: 34274 reply_id: 334274[/import]

First, you should just use:

display.newText()  

as display.newRetinaText() has been deprecated.

You can center by doing the following:

myText2:setReferencePoint(display.CenterReferencePoint)  
myText2.x = display.contentCenterX -- or it will center on whatever X you set  

Technically you don’t need to set the reference point because it will default to center reference point. When you put in an X, Y as part of a parameter (display.newText, display.newRect, etc.), the assumption is TopLeftReferencePoint, but it gets set so that any future setting of object.x and object.y are center referenced.
[import]uid: 199310 topic_id: 34274 reply_id: 136284[/import]

The centering will not work if you specify a height in newText(). Setting the height to 0 will make centering work, and will automatically adjust the height for multi-line text.
Please note that for multi-line text, each line will *not* be centered. The multi-line text will be treated as a block of left-justified text, and the block will be centered. [import]uid: 70847 topic_id: 34274 reply_id: 136301[/import]

First, you should just use:

display.newText()  

as display.newRetinaText() has been deprecated.

You can center by doing the following:

myText2:setReferencePoint(display.CenterReferencePoint)  
myText2.x = display.contentCenterX -- or it will center on whatever X you set  

Technically you don’t need to set the reference point because it will default to center reference point. When you put in an X, Y as part of a parameter (display.newText, display.newRect, etc.), the assumption is TopLeftReferencePoint, but it gets set so that any future setting of object.x and object.y are center referenced.
[import]uid: 199310 topic_id: 34274 reply_id: 136284[/import]

The centering will not work if you specify a height in newText(). Setting the height to 0 will make centering work, and will automatically adjust the height for multi-line text.
Please note that for multi-line text, each line will *not* be centered. The multi-line text will be treated as a block of left-justified text, and the block will be centered. [import]uid: 70847 topic_id: 34274 reply_id: 136301[/import]