Search code examples
javalibgdxshaderfragment-shader

Setting fontColor for ImageTextButton works in one screen but not on another - LIBGDX Scene2D


I have two ImageTextbuttons and this is how I set them up in my MainMenu screen and in the Game screen:

    ImageTextButton.ImageTextButtonStyle ibs = new ImageTextButton.ImageTextButtonStyle();
    ibs.font = skin.getFont("scorescombo3-font160");
    ibs.fontColor = new Color(1.0f, 0.6f, 0.0f, 0.65f);
    ibs.up = new TextureRegionDrawable(skin.getRegion("level_name"));
    level_no_button = new ImageTextButton("button", ibs);

I use the same font files exported from Hiero.

In my Game screen I see the text as Orange as it's supposed to be seen but in my MainMenu screen it remains White even though the Alpha is rendered correctly.

I've searched for all level_no_button color setups inside my code and there is no line where I set the color to white. Why does color setting work on one screen but not on the other? More so , why does alpha work but color doesn't?


Solution

  • Apparently it was the shader in the other screen drawing the font in white.

    I changed :

      vec4 texColor  = texture2D(u_texture, v_texCoord);
    

    to : varying vec4 v_color; ...

      vec4 texColor  = texture2D(u_texture, v_texCoord) * v_color;
    

    and that fixed my issue.