[英]How to set the format of text in Korge?
The2048 Game tutorial shows 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)
}
I use android studio 4.1 and Korge plugin 1.12.2.2.我使用 android studio 4.1 和 Korge 插件 1.12.2.2。 The IDE shows: Unresolved reference. IDE 显示:未解决的参考。
I change this line to我将此行更改为
setFormat(align = TextAlignment.MIDDLE_CENTER)
The error of IDE disappear, but the text don't show either. IDE 的错误消失了,但文字也不显示。
How to fix it, and set the text in the middle of the object of bgScore如何修复它,并将文本设置在 bgScore 的object 中间
Thanks a lot非常感谢
The korge in new version新版本的科尔格
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.