0
我如何創建和繪製圖像以從我的資產設置背景?如何在MainScreen菜單(此處)添加背景圖像?
public class MainScreen extends AbstractScreen {
private SpriteBatch batch;
private Button exit, play;
public MainScreen(Main main) {
super(main);
}
public void show(){
batch= main.getBatch();
Texture texture = new Texture(Gdx.files.internal("BotonExit.png"));
int centroY = Gdx.graphics.getHeight()/2 - texture.getHeight()/2;
int centroX = Gdx.graphics.getWidth()/2 - texture.getWidth()/2;
exit = new ButtonExit(centroX, centroY - 50);
play = new ButtonPlay(centroX, centroY + 50);
}
public void render(float delta){
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
exit.update();
play.update();
batch.begin();
exit.draw(batch);
play.draw(batch);
batch.end();
}
}
謝謝,但仍然沒有工作,當我把私人最終,可以使用MainScreen,和我不能使用的方法setSize和我不能得出我不後臺知道爲什麼,也許因爲我在另一堂課有另一個背景,或者我不知道。有任何想法嗎? – JAnoob92 2014-10-03 10:06:00
嘗試實現屏幕不擴展AbstractScreen將重寫呈現方法 – adnbsr 2014-10-03 14:53:15