3

次のようにサイズ変更メソッドで行っているフェードインフェードアウトのようなアニメーション化されたスプラッシュスクリーンが必要です

public class SplashScreen extends GamePlayScreen {

@Override
public void resize(int width, int height) {
    super.resize(width, height);
    stage.clear();
    Drawable splashDrawable = new TextureRegionDrawable(region);
    splashImage = new Image(splashDrawable, Scaling.stretch);
    splashImage.setFillParent(true);
    splashImage.getColor().a = 0f;
    splashImage.addAction(Actions.sequence(Actions.fadeIn(0.75f),
            Actions.delay(1.75f), Actions.fadeOut(0.75f), 
            new Action() {
                @Override
                public boolean act(float delta) {
                    // the last action will move to the next screen
                    System.out.println("moving to next screen");
                    splashGameObj.setScreen(new GamePlayScreen(
                            splashGameObj));
                    return true;
                }
            }));
    stage.addActor(splashImage);
  }
}
4

2 に答える 2

2

この変数を宣言する

private Stage stage;    

@Override
public void render(float delta) {
    // TODO Auto-generated method stub
    update();
    draw(delta);
}

private void draw(float delta) {
    // TODO Auto-generated method stub
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);

    stage.act(delta);
    stage.draw()
}

@Override
public void resize(int width, int height) {
    stage.setViewport( width, height, true );

}

@Override
public void show() {
    // TODO Auto-generated method stub
    stage = new Stage();
    Gdx.input.setInputProcessor(stage);

    Image splashImage = new Image(region);
    splashImage.addAction( Actions.sequence( Actions.fadeOut( 0.0001f ), Actions.fadeIn( 5f ),
            Actions.run(onSplashFinishedRunnable) ) );



    stage.addActor(splashImage);
}

Runnable onSplashFinishedRunnable = new Runnable() {

    @Override
    public void run() {
        // TODO Auto-generated method stub
        splashGameObj.setScreen(new GamePlayScreen(splashGameObj));
    }
};
于 2013-04-13T12:33:47.450 に答える