Java LibGdx font.setColor(Color.WHITE)不工作
}Java LibGdx font.setColor(Color.WHITE)不工作,java,libgdx,Java,Libgdx,} 我想在图像中打印字母“SHOP”。但是,图像是深灰色的,因此我尝试将字母“SHOP”以白色打印为font.setColor(color.white),但这不起作用。使用ribbonStyle.fontColor public void show() { buttonsAtlas = new TextureAtlas("spellButton.pack"); //button atlas image buttonSkin = new Skin(); buttonSkin
我想在图像中打印字母“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
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);
这并不能解决我的问题。。“商店”一词仍以黑色显示。我通过AngelCode生成我的字体,如果这有帮助的话:(@Yukii是你的字体纹理黑色吗?字体纹理应该是白色的,因为你可以把白色变成颜色,但可以把颜色变成白色。@Yukii就像我说的,你不能把黑色纹理变成白色,这是颜色的本质。把原始纹理变成白色,然后做
设置颜色(Color.black)
当您需要它为黑色时。同样适用于setColor(Color.WHITE)
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);
}