Text Alignment

Is there someway to Alignment my text? Like justify in word…
Thanks! [import]uid: 32005 topic_id: 6991 reply_id: 306991[/import]

dmpellegrino,

Although there is no justification function, the code snipit below offers a possible alternative.

– Justify Text
– Ed Wainwright so-lights.com

display.setStatusBar( display.HiddenStatusBar )

local introGroup = display.newGroup()

– local background = display.newImage(“background.png”)

– Right Justified text, for scores and variable length text
– object:setReferencePoint( referencePoint )
– display.TopRightReferencePoint
local mscore1 = 19
local score1 = display.newText(mscore1, 290, 70, nill,18)
score1:setTextColor(0,255,0)
score1:setReferencePoint(display.TopRightReferencePoint)
score1.x = 330; score1.y = 5

local mscore2 = 1019
local score2 = display.newText(mscore2, 290, 70, nill,18)
score2:setTextColor(0,255,0)
score2:setReferencePoint(display.TopRightReferencePoint)
score2.x = 330; score2.y = 30

local mscore3 = 1001019
local score3 = display.newText(mscore3, 290, 70, nill,18)
score3:setTextColor(0,255,0)
score3:setReferencePoint(display.TopRightReferencePoint)
score3.x = 330; score3.y = 55

– Center Justified text, for variable length text
– object:setReferencePoint( referencePoint )
– display.TopCenterReferencePoint
local mtitle1 = “This is the Main Title”
local title1 = display.newText(mtitle1, 290, 70, nill,18)
title1:setTextColor(0,255,0)
title1:setReferencePoint(display.TopCenterReferencePoint)
title1.x = 170; title1.y = 75

local mtitle2 = “This is long Main Title, centered”
local title2 = display.newText(mtitle2, 290, 70, nill,18)
title2:setTextColor(0,255,0)
title2:setReferencePoint(display.TopCenterReferencePoint)
title2.x = 170; title2.y = 100

local mtitle3 = “Short Title”
local title3 = display.newText(mtitle3, 290, 70, nill,18)
title3:setTextColor(0,255,0)
title3:setReferencePoint(display.TopCenterReferencePoint)
title3.x = 170; title3.y = 125

– Left Justified text, for variable length text
– object:setReferencePoint( referencePoint )
– display.TopLeftReferencePoint
local mtext1 = “This main.lua is a demonistration of”
local text1 = display.newText(mtext1, 290, 70, nill,18)
text1:setTextColor(0,255,0)
text1:setReferencePoint(display.TopLeftReferencePoint)
text1.x = 10; text1.y = 155

local mtext2 = “the object:setReferencePoint() function”
local text2 = display.newText(mtext2, 290, 70, nill,18)
text2:setTextColor(0,255,0)
text2:setReferencePoint(display.TopLeftReferencePoint)
text2.x = 10; text2.y = 180

local mtext3 = “can be used to simulate right, center,”
local text3 = display.newText(mtext3, 290, 70, nill,18)
text3:setTextColor(0,255,0)
text3:setReferencePoint(display.TopLeftReferencePoint)
text3.x = 10; text3.y = 205

local mtext4 = “and left justification, Thanks Ed”
local text4 = display.newText(mtext4, 290, 70, nill,18)
text4:setTextColor(0,255,0)
text4:setReferencePoint(display.TopLeftReferencePoint)
text4.x = 10; text4.y = 230

introGroup:insert(background)
introGroup:insert(score1)
introGroup:insert(score2)
introGroup:insert(score3)
introGroup:insert(title1)
introGroup:insert(title2)
introGroup:insert(title3)
introGroup:insert(text1)
introGroup:insert(text2)
introGroup:insert(text3)
introGroup:insert(text4) [import]uid: 8102 topic_id: 6991 reply_id: 64640[/import]

Just helping to make it clear for reading:

[lua]-- Justify Text
– Ed Wainwright so-lights.com

display.setStatusBar( display.HiddenStatusBar )

local introGroup = display.newGroup()

– local background = display.newImage(“background.png”)

– Right Justified text, for scores and variable length text
– object:setReferencePoint( referencePoint )
– display.TopRightReferencePoint
local mscore1 = 19
local score1 = display.newText(mscore1, 290, 70, nill,18)
score1:setTextColor(0,255,0)
score1:setReferencePoint(display.TopRightReferencePoint)
score1.x = 330; score1.y = 5

local mscore2 = 1019
local score2 = display.newText(mscore2, 290, 70, nill,18)
score2:setTextColor(0,255,0)
score2:setReferencePoint(display.TopRightReferencePoint)
score2.x = 330; score2.y = 30

local mscore3 = 1001019
local score3 = display.newText(mscore3, 290, 70, nill,18)
score3:setTextColor(0,255,0)
score3:setReferencePoint(display.TopRightReferencePoint)
score3.x = 330; score3.y = 55

– Center Justified text, for variable length text
– object:setReferencePoint( referencePoint )
– display.TopCenterReferencePoint
local mtitle1 = “This is the Main Title”
local title1 = display.newText(mtitle1, 290, 70, nill,18)
title1:setTextColor(0,255,0)
title1:setReferencePoint(display.TopCenterReferencePoint)
title1.x = 170; title1.y = 75

local mtitle2 = “This is long Main Title, centered”
local title2 = display.newText(mtitle2, 290, 70, nill,18)
title2:setTextColor(0,255,0)
title2:setReferencePoint(display.TopCenterReferencePoint)
title2.x = 170; title2.y = 100

local mtitle3 = “Short Title”
local title3 = display.newText(mtitle3, 290, 70, nill,18)
title3:setTextColor(0,255,0)
title3:setReferencePoint(display.TopCenterReferencePoint)
title3.x = 170; title3.y = 125

– Left Justified text, for variable length text
– object:setReferencePoint( referencePoint )
– display.TopLeftReferencePoint
local mtext1 = “This main.lua is a demonistration of”
local text1 = display.newText(mtext1, 290, 70, nill,18)
text1:setTextColor(0,255,0)
text1:setReferencePoint(display.TopLeftReferencePoint)
text1.x = 10; text1.y = 155

local mtext2 = “the object:setReferencePoint() function”
local text2 = display.newText(mtext2, 290, 70, nill,18)
text2:setTextColor(0,255,0)
text2:setReferencePoint(display.TopLeftReferencePoint)
text2.x = 10; text2.y = 180

local mtext3 = “can be used to simulate right, center,”
local text3 = display.newText(mtext3, 290, 70, nill,18)
text3:setTextColor(0,255,0)
text3:setReferencePoint(display.TopLeftReferencePoint)
text3.x = 10; text3.y = 205

local mtext4 = “and left justification, Thanks Ed”
local text4 = display.newText(mtext4, 290, 70, nill,18)
text4:setTextColor(0,255,0)
text4:setReferencePoint(display.TopLeftReferencePoint)
text4.x = 10; text4.y = 230

introGroup:insert(background)
introGroup:insert(score1)
introGroup:insert(score2)
introGroup:insert(score3)
introGroup:insert(title1)
introGroup:insert(title2)
introGroup:insert(title3)
introGroup:insert(text1)
introGroup:insert(text2)
introGroup:insert(text3)
introGroup:insert(text4)[/lua] [import]uid: 89165 topic_id: 6991 reply_id: 64651[/import]

@edwainwright

This is good, I just want to do something to align my top 10 highest score.

Thanks [import]uid: 94613 topic_id: 6991 reply_id: 65426[/import]

RSCdev,

Thank You

Ed [import]uid: 8102 topic_id: 6991 reply_id: 66150[/import]

Hello Ed,

Youre Welcome!
Cheers!
Rodrigo. [import]uid: 89165 topic_id: 6991 reply_id: 66153[/import]