Draw string with BitmapFont

回眸只為那壹抹淺笑 提交于 2019-12-24 12:07:56

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!