java - LibGdx font.setColor(Color.WHITE) 不起作用

标签 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) 但这不起作用。

最佳答案

改用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); 

}

关于java - LibGdx font.setColor(Color.WHITE) 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37094151/

相关文章:

java - 为什么我的 Lib-GDX 项目不是 GWT 项目?

Java 安卓套接字

java - 使用 JMS 重试机制记录异常情况

java - 如何按实体的 Y 值对实体的 ArrayList 进行排序?

java - 为什么 touchUp 方法不触发?

java - 将文件中的每一行设置为 java libgdx 中的 GlyphLayout

java - 调整 GC 有帮助吗?

java - 向实现 org.springframework.amqp.rabbit.connection.ConnectionListener 的类通知 channel 关闭

javascript - 想要读取网络浏览器上显示的网址

java - 窗口移动导致增量时间不正确