From 6ed7d19c96097106fd6b140522a02e871d599515 Mon Sep 17 00:00:00 2001 From: LeHaine Date: Mon, 22 Jan 2024 11:24:04 -0500 Subject: [PATCH] game: update to truly center text and rect --- game/src/commonMain/kotlin/com/game/template/Game.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/game/src/commonMain/kotlin/com/game/template/Game.kt b/game/src/commonMain/kotlin/com/game/template/Game.kt index c3611ac..1a0291d 100644 --- a/game/src/commonMain/kotlin/com/game/template/Game.kt +++ b/game/src/commonMain/kotlin/com/game/template/Game.kt @@ -2,10 +2,12 @@ package com.game.template import com.lehaine.littlekt.Context import com.lehaine.littlekt.ContextListener +import com.lehaine.littlekt.graph.node.resource.HAlign import com.lehaine.littlekt.graphics.Color import com.lehaine.littlekt.graphics.Fonts -import com.lehaine.littlekt.graphics.g2d.* +import com.lehaine.littlekt.graphics.g2d.SpriteBatch import com.lehaine.littlekt.graphics.g2d.shape.ShapeRenderer +import com.lehaine.littlekt.graphics.g2d.use import com.lehaine.littlekt.graphics.gl.ClearBufferMask import com.lehaine.littlekt.graphics.toFloatBits import com.lehaine.littlekt.math.geom.degrees @@ -33,8 +35,8 @@ class Game(context: Context) : ContextListener(context) { gl.clear(ClearBufferMask.COLOR_BUFFER_BIT) batch.use(camera.viewProjection) { - Fonts.default.draw(it, "Hello LittleKt!", -15f, 0f) - shapeRenderer.filledRectangle(-25f, 50f, 100f, 50f, rotation, color = Color.RED.toFloatBits()) + Fonts.default.draw(it, "Hello LittleKt!", 0f, 0f, align = HAlign.CENTER) + shapeRenderer.filledRectangle(-50f, 50f, 100f, 50f, rotation, color = Color.RED.toFloatBits()) } rotationTimer += dt if (rotationTimer > 10.milliseconds) {