Reputation: 103
I'm not sure if you're not allowed to call font.draw() twice but the first linedisplays correctly but the second one is very glitchy, a lot of letters are missing [that appear fine in the first line] and random numbers seem to not draw. My .fnt file is fine as it works on buttons and checkbox's just fine.
Here's some of my code:
private BitmapFont font = new BitmapFont(Gdx.files.internal("test.fnt"),false);
private SpriteBatch batch = new SpriteBatch();
//in Render Method
batch.begin();
font.draw(batch, "Best Distance: " + bestDistance + "m", Gdx.graphics.getHeight() / 2, Gdx.graphics.getWidth() / 2);
font.draw(batch, "Distance: " + finalDistance + "m", Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
stage.draw();
hud.stage.draw();
batch.end();
If I switch the order of their draw call then whichever one is called first draws correctly.
Upvotes: 1
Views: 65
Reputation:
You're calling stage.draw()
without closing the spritebatch. Simply call batch.end()
before starting to draw the stage.
Rendering a batch inside another opened batch will result in all kind of weird behaviour that makes you think the fault lies in everything but the batch.
This is a similar problem.
Upvotes: 2