Skip to content

Commit

Permalink
Fix score text position after screen resize
Browse files Browse the repository at this point in the history
  • Loading branch information
manolol1 committed Jan 10, 2024
1 parent 8ff8a3c commit cfde45b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion core/src/xyz/manolol/squarecollector/GameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions core/src/xyz/manolol/squarecollector/TextWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit cfde45b

Please sign in to comment.