I've tried several examples on how to right justify text in Lua. So far, I have been unsuccessful. I am using Corona Sdk. Any advice is appreciated. Jerry
Maybe this will work:
local textObj = display.newText(.....);
textObj:setReferencePoint(display.CenterRightReferencePoint);
textObj.x = 100;
In new builds of Corona SDK that have graphics 2.0, you need to do this:
rowScore.anchorX = 1
Where rowScore
is your variable created with display.newText
. Here's a full example:
local rowScore = display.newText({
text="My Score",
fontSize=40
})
rowScore.anchorX = 1
rowScore.x = 30
rowScore.y = 100
Notice that I didn't used the align="right"
parameter because it was working on the Windows Simulator but it was not working on Android.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.