3
\$\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\$
2
  • \$\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\$ Commented Dec 1, 2017 at 16:17
  • \$\begingroup\$ Have you tried through Labels ? \$\endgroup\$ Commented Dec 7, 2017 at 14:25

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.