How to center text regardless of width?

Hello,

How do i center a text regardless of the width please?

Thank You!

Set the anchorX to .5 and use the display.contentCenterX reference location.

Sorry i didn’t get it, can u provide an example please?

Thanks again!

anyone please?

I haven’t gotten into G2 configurations so I can’t test this, but it should look something like this;

testText1 = display.newText(“this is a test”, display.contentWidth/2, display.contentHeight/2, 0, 0, “helvetica”, 1)

testText1.anchorX = .5

testText1.x = display.contentWidth/2

if that doesn’t work, I’m out of ideas.

Doesn’t work :frowning:

Anybody else??? I will be very thankful for your help!!!

Set the anchorX to .5 and use the display.contentCenterX reference location.

Sorry i didn’t get it, can u provide an example please?

Thanks again!

anyone please?

I haven’t gotten into G2 configurations so I can’t test this, but it should look something like this;

testText1 = display.newText(“this is a test”, display.contentWidth/2, display.contentHeight/2, 0, 0, “helvetica”, 1)

testText1.anchorX = .5

testText1.x = display.contentWidth/2

if that doesn’t work, I’m out of ideas.

Doesn’t work :frowning:

Anybody else??? I will be very thankful for your help!!!