问题
Sorry for that stupid question but I'm a quiet noob. I can't figure out how to draw Bitmap Font in Libgdx. Well, I've used HIERO v2.0 tool to make BitmapFont file. Then I initialize it in code:
BitmapFont font = new BitmapFont(Gdx.files.internal("data/fonts/Georgia.fnt"), Gdx.files.internal("data/fonts/Georgia.png"), false);
But when I try to draw it on screen:
game.batch.begin();
font.draw(game.batch, "Text string", game.screenWidth * 0.5f, game.screenHeight * 0.5f);
game.batch.end();
I get this result: http://imageshack.us/photo/my-images/696/bitmapfont.png/ Does anybody know, what I'm doing wrong?
回答1:
This tends to happen when the Georgia.fnt and Georgia.png are out of sync. That is, they are from different exports.
Double check that you saved both in HIERO
来源:https://stackoverflow.com/questions/10253448/draw-string-with-bitmapfont