简体   繁体   中英

How to set the format of text in Korge?

The2048 Game tutorial shows

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. The IDE shows: Unresolved reference.

I change this line to

setFormat(align = TextAlignment.MIDDLE_CENTER)

The error of IDE disappear, but the text don't show either.

How to fix it, and set the text in the middle of the object of bgScore

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)
}

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM