gogonapel
gogonapel

Reputation: 788

Fonts created in Hiero can't set the color with new Color(r,g,b,a); - LIBGDX

I generated some fonts in Hiero. If I set the font color with :

    fontFPS.setColor(Color.YELLOW);

the text color it is drawn correctly.

But if I set it with

    Color fpsColor = new Color(74f, 112f, 139f, 160f);      
    fontFPS.setColor(fpsColor); 

then I only get white color with no alpha. What is the problem?

Upvotes: 0

Views: 83

Answers (1)

Igor
Igor

Reputation: 1855

First of all float values inside that method should be from 0f to 1f. So your color should be (values I put in constructor are calculated by dividing your original values with 255)

Color fpsColor = new Color(0.29f, 0.43f, 0.54f, 0.66f);

Also you should enable blending like this (I'm not sure if you already did that)

 Gdx.gl.glEnable(GL10.GL_BLEND);
 Gdx.gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA)

Upvotes: 1

Related Questions