如何在Lua中右对齐文本?

我尝试了几个 Lua 中右对齐文本的示例,但目前为止都没有成功。我正在使用 Corona Sdk。感谢任何建议。Jerry

点赞
用户1847592
用户1847592

也许这个会生效:

local textObj = display.newText(.....);
textObj:setReferencePoint(display.CenterRightReferencePoint);
textObj.x = 100;
2013-03-28 03:23:51
用户736007
用户736007

在拥有图形 2.0 的 Corona SDK 的新版本中,你需要这样做:

rowScore.anchorX = 1

其中 rowScore 是你使用 display.newText 创建的变量。 以下是一个完整的示例:

local rowScore = display.newText({
    text="My Score",
    fontSize=40
})
rowScore.anchorX = 1
rowScore.x = 30
rowScore.y = 100

请注意,我没有使用 align="right" 参数,因为它在 Windows 模拟器上工作得很好,但在 Android 上没有工作。

2013-12-28 21:09:38