[英]How to set the format of text in Korge?
2048游戏教程显示
text("0", cellSize * 0.5, Colors.WHITE, font) {
setTextBounds(Rectangle(0.0, 0.0, bgScore.width, cellSize - 24.0))
format = format.copy(align = Html.Alignment.MIDDLE_CENTER) // there is an error
centerXOn(bgScore)
alignTopToTopOf(bgScore, 12.0)
}
我使用 android studio 4.1 和 Korge 插件 1.12.2.2。 IDE 显示:未解决的参考。
我将此行更改为
setFormat(align = TextAlignment.MIDDLE_CENTER)
IDE 的错误消失了,但文字也不显示。
如何修复它,并将文本设置在 bgScore 的object 中间
非常感谢
新版本的科尔格
text("0", cellSize * 0.5, Colors.WHITE, font) {
setTextBounds(Rectangle(0.0, 0.0, bgScore.width, cellSize - 24.0))
// format = format.copy(align = Html.Alignment.MIDDLE_CENTER) // there is an error
alignment = TextAlignment.MIDDLE_CENTER // it works in version korGE 2.0
centerXOn(bgScore)
alignTopToTopOf(bgScore, 12.0)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.