I'm starting to make a game, and the first screen I've made is a very simple loading screen with some centered text.
On starting it up, the text is nicely centered:
Then I resize the window, and I get:
Why is it stretched? And why has it moved? Looking at my code it looks like everything should be perfectly centered:
public void render(float delta) {
Gdx.gl.glClearColor(0, 0, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
if (Assets.manager.update()) {
// Eventually change to a main menu or something
}
String text = "Loading " + Math.round(Assets.manager.getProgress()) + "%";
BitmapFont.TextBounds bounds = fnt.getBounds(text);
batch.begin();
fnt.draw(batch, text, (Gdx.graphics.getWidth()/2)-(bounds.width/2), (Gdx.graphics.getHeight()/2)-(bounds.height/2));
batch.end();
}
No comments:
Post a Comment