LibGdx font.setColor(Color.WHITE)无效

时间:2016-05-07 22:00:42

标签: java libgdx

public void show()
{
    buttonsAtlas = new TextureAtlas("spellButton.pack"); //button atlas image
    buttonSkin = new Skin();
    buttonSkin.addRegions(buttonsAtlas);
    font = new BitmapFont(Gdx.files.internal("WhiteAlpha.fnt"), false); //the font
    font.setColor(Color.WHITE);

    stage = new Stage(); // window is stage
    stage.clear();

    TextButton.TextButtonStyle ribbonStyle = new TextButton.TextButtonStyle(); //Shop title ribbon properties
    ribbonStyle.up = buttonSkin.getDrawable("ribbon");
    ribbonStyle.down = buttonSkin.getDrawable("ribbon");
    ribbonStyle.font = font;

    ribbon = new TextButton("SHOP", ribbonStyle);  //shop title outlook adn textstyle
    ribbon.setPosition(200, 1720);
    ribbon.setSize(880, 200);

}

我想打印这封信" SHOP"在图像内。然而,图像是深灰色的,所以我试图打印字母" SHOP"在白色为font.setColor(Color.WHITE),但这不起作用。

1 个答案:

答案 0 :(得分:2)

改为使用ribbonStyle.fontColor

public void show()
{
    buttonsAtlas = new TextureAtlas("spellButton.pack"); //button atlas image
    buttonSkin = new Skin();
    buttonSkin.addRegions(buttonsAtlas);
    font = new BitmapFont(Gdx.files.internal("WhiteAlpha.fnt"), false); //the font

    stage = new Stage(); // window is stage
    stage.clear();

    TextButton.TextButtonStyle ribbonStyle = new TextButton.TextButtonStyle(); //Shop title ribbon properties
    ribbonStyle.up = buttonSkin.getDrawable("ribbon");
    ribbonStyle.down = buttonSkin.getDrawable("ribbon");
    ribbonStyle.font = font;

    // change it here (per style)
->  ribbonStyle.fontColor = Color.WHITE;

    ribbon = new TextButton("SHOP", ribbonStyle);  //shop title outlook adn textstyle
    ribbon.setPosition(200, 1720);
    ribbon.setSize(880, 200);

    // or, you can change it here (per button)
->  ribbon.setColor(Color.WHITE); 

}