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/