0
我正在使用java,libgdx,scence2d。如何在創建字體顏色後更改字體顏色
我已經在構造函數中設置了bitMapFont。現在如何在創建字體後更改字體顏色?我想改變渲染方法。
這是我的構造函數在那裏我的標題和的菜單項(3個按鈕)
public menuScreen() {
sb = new SpriteBatch();
stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(),
true);
bitMapFont = new BitmapFont(Gdx.files.internal("font/font.fnt"), false);
labelStyle = new LabelStyle(bitMapFont, Color.WHITE);
label = new Label("Asteroids", labelStyle);
float width = bitMapFont.getBounds(title).width;
label.setPosition((Gdx.graphics.getWidth() - width)/2,
(Gdx.graphics.getHeight()) - 100);
stage.addActor(label);
//menu items
menuItems = new String[] { "Play", "HighScores", "Quit" };
label2 = new Label(menuItems[0], labelStyle);
label2.setPosition((Gdx.graphics.getWidth() - width)/2,
(180 - 35 * 0));
label3 = new Label(menuItems[1], labelStyle);
label3.setPosition((Gdx.graphics.getWidth() - width)/2,
(180 - 35 * 1));
label4 = new Label(menuItems[2], labelStyle);
label4.setPosition((Gdx.graphics.getWidth() - width)/2,
(180 - 35 * 2));
stage.addActor(label2);
stage.addActor(label3);
stage.addActor(label4);
}
平局標題和菜單項
public void draw() {
sb.setProjectionMatrix(MyGdxGame.camera.combined);
sb.begin();
//if user press 'Play' menu item
if(currentItem == 1){
//How to change label2 color??????
}
// update and draw stage
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
sb.end();
}
你能否提一下這是哪種語言..也可以用該語言標記問題 –