Can't change font color in Libgdx

ruff1991 picture ruff1991 · Oct 6, 2012 · Viewed 13.6k times · Source

I'm trying to change the color of the font I use in my application. But whatever I try the font remains black. I made this font using Hiero font tool.

My code is something like this:

SpriteBatch batch = new SpriteBatch();
BitmapFont font = new BtimapFont( Gdx.files.internal(MainAssets.pathToAssets + "font/comic.fnt"), Gdx.files.internal(MainAssets.pathToAssets +  "font/comic.png"), false );

In render where I draw the font:

batch.begin();
font.setColor(1, 0, 0, 1);
font.draw(batch, "Hello World!", 0, 0);
batch.end();

I found a similar issue to mine but there was still no solution.

http://code.google.com/p/libgdx/issues/detail?id=370

Answer

far picture far · May 21, 2013

You need to set output format with 32-bit depth and white colour with alpha (in case you are using BMFont tool, dont know about the Hiero ).