From cfde45baba67948395698008f09f5bd46aa367e8 Mon Sep 17 00:00:00 2001 From: Mario Ebenhofer Date: Wed, 10 Jan 2024 19:15:02 +0100 Subject: [PATCH] Fix score text position after screen resize --- core/src/xyz/manolol/squarecollector/GameScreen.java | 3 ++- core/src/xyz/manolol/squarecollector/TextWriter.java | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/core/src/xyz/manolol/squarecollector/GameScreen.java b/core/src/xyz/manolol/squarecollector/GameScreen.java index dae4dad..ca664ed 100644 --- a/core/src/xyz/manolol/squarecollector/GameScreen.java +++ b/core/src/xyz/manolol/squarecollector/GameScreen.java @@ -147,8 +147,9 @@ public void render(float delta) { shapeRenderer.end(); + batch.setProjectionMatrix(camera.combined); batch.begin(); - textWriter.DrawTextTopRightXY("" + score, 60, 50, 0); + textWriter.DrawTextTopRightXY("" + score, 60, 30, 0); batch.end(); } diff --git a/core/src/xyz/manolol/squarecollector/TextWriter.java b/core/src/xyz/manolol/squarecollector/TextWriter.java index a05eb5c..71a9638 100644 --- a/core/src/xyz/manolol/squarecollector/TextWriter.java +++ b/core/src/xyz/manolol/squarecollector/TextWriter.java @@ -59,8 +59,8 @@ public void drawTextCenterXY(String text, int fontSize, float yOffset, float r, public void DrawTextTopRightXY(String text, int fontSize, float xOffset, float yOffset) { BitmapFont font = getFont(fontSize); layout.setText(font, text); - float x = (viewport.getWorldWidth() - layout.width) - xOffset; - float y = (viewport.getWorldHeight() - layout.height) - yOffset; + float x = (viewport.getWorldWidth() - xOffset) - layout.height; + float y = (viewport.getWorldHeight() - yOffset) - layout.height; font.draw(batch, layout, x, y); }