How to draw smooth text in libgdx?

前端 未结 10 1284
暖寄归人
暖寄归人 2020-12-01 00:01

I try to draw simple text in my android game on libgdx, but it\'s look sharp. How to make text look smooth in different resolutions? My Code:



        
10条回答
  •  感动是毒
    2020-12-01 00:41

    • Create a .fnt file using hiero which is provided by libgdx website.
    • Set the size of font to 150; it will create a .fnt file and a .png file.
    • Copy both files into your assets folder.
    • Now declare the font:

      BitmapFont font;
      
    • Now in create method:

      font = new BitmapFont(Gdx.files.internal("data/100.fnt"), false); // 100 is the font name you can give your font any name
      
    • In render:

      font.setscale(.2f);
      
      font.draw(batch, "whatever you want to write", x,y);
      

提交回复
热议问题