1

过去 3 周我一直在使用libgdx.. 我创建了两个引用游戏的屏幕:

public class Game extends Game {

TitleScreen titleScreen;
SplashScreen splashScreen;

@Override
public void create() {
    // TODO Auto-generated method stub
    titleScreen = new TitleScreen(this);
    splashScreen = new SplashScreen(this);
    setScreen(splashScreen);

}

}

public class SplashScreen implements Screen {

Game game;

public SplashScreen(Game game) {
    // TODO Auto-generated constructor stub
    this.game = game;
    }


@Override
public void show() {
    // TODO Auto-generated method stub
}

@Override
public void hide() {
    // TODO Auto-generated method stub
}

@Override
public void render(float delta) {
    // TODO Auto-generated method stub
    Gdx.gl.glClearColor(0.5f, 1f, 1f, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    if(Gdx.input.justTouched()){
        game.splashScreen.dispose();
        game.setScreen(game.titlescreen);
    }

}

@Override
public void resize(int width, int height) {
    // TODO Auto-generated method stub

}

@Override
public void pause() {
    // TODO Auto-generated method stub

}

@Override
public void resume() {
    // TODO Auto-generated method stub

}

@Override
public void dispose() {
    // TODO Auto-generated method stub


}

我如何splashscreen完全处置?当我game.setscreen(game.splashscreen)titlescreen课堂上打电话时,它恢复了splashscreen;。我期待设置一个新的splashscreen..

4

1 回答 1

0

每次您想从头开始显示启动画面时,都创建一个新的启动画面:

game.setScreen(new SplashScreen(game));
于 2012-10-20T02:52:38.533 回答