2
\$\begingroup\$

I want to change the color of my libGDX BitmapFont, but it can't change it. The font is generated with Hiero v5 (Lastest as I Know) but the color of the font doesn't change. Here is the example code, the important part here is how modify the alpha channel for an animation I want.

font = new BitmapFont(game.getAssets().getFont(0.9f).getData(), game.getAssets().getFont(0.9f).getRegion(), false);
textLayout = new GlyphLayout(font, "Tap to Start");
textPosition = new Vector2();
textPosition.x = Constants.HALF_WIDTH - (textLayout.width/2);
textPosition.y = 150;
//font.setColor(255f/255f, 183f/255f, 77f/255f, 0.3f); This doesn't work as well
font.getCache().setColor(255f/255f, 183f/255f, 77f/255f, 0.3f);

//Font Drawing in render Method
font.draw(batch, textLayout, textPosition.x, textPosition.y);

Here is a screen of the result of this code (color doesn't change).

Color doesn't Change

Font resource image has white letters and transparent background.

\$\endgroup\$
  • \$\begingroup\$ yes my friend, look at the comented code //font.setColor(255f/255f, 183f/255f, 77f/255f, 0.3f); This doesn't work as well \$\endgroup\$ – user2963359 Dec 1 '17 at 16:17
  • \$\begingroup\$ Have you tried through Labels ? \$\endgroup\$ – Sebastien Servouze Dec 7 '17 at 14:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.