0

我一直试图让我的应用程序从一个场景变为另一个场景。我所做的是 onLoadScene() 我将它定向到一个具有场景的方法,而我试图做的是设置另一个场景在另一个方法中......但我得到的是第一个场景中的精灵卡在屏幕 !

有人可以帮我教我如何在同一个班级从一个场景切换到另一个场景。

这是我的代码:

@Override
public Scene onLoadScene() {
    return splashGame();
}

private Scene splashGame(){
    final Scene sceneGameSplash = new Scene();

    sceneGameSplash.setBackgroundEnabled(false);

    System.out.println("pls work 1");
    final Sprite splashSprite = new Sprite(0,0, this.gameSplashScreenRegion);

    sceneGameSplash.registerUpdateHandler(new TimerHandler(3f, true, new ITimerCallback() {
          @Override
          public void onTimePassed(final TimerHandler pTimerHandler) {
            sceneGameSplash.unregisterUpdateHandler(pTimerHandler);

            System.out.println("pls work");


            splashUnjum();
          }
    }));

    splashSprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    splashSprite.setHeight(display.getHeight());
    splashSprite.setWidth(display.getWidth());

    sceneGameSplash.attachChild(splashSprite);


    return sceneGameSplash;

}

private Scene splashUnjum(){

    final Scene sceneUnjumSplash = new Scene();
    this.mEngine.setScene(sceneUnjumSplash);

     System.out.println("pls work 2");
    final Sprite splashUnjumSprite = new Sprite(0,0,this.gamevedaSplashScreenRegion);
    splashUnjumbleSprite.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
    splashUnjumSprite.setHeight(display.getHeight());
    splashUnjumSprite.setWidth(display.getWidth());

    sceneUnjumSplash.attachChild(splashUnjumSprite);

    sceneUnjumSplash.registerUpdateHandler(new TimerHandler(3f, true, new ITimerCallback() {
        @Override
        public void onTimePassed(final TimerHandler pTimerHandler) {
            sceneUnjumSplash.unregisterUpdateHandler(pTimerHandler);

            System.out.println("pls work yo");

            mainMenu();
        }
    }));


    return sceneUnjumSplash;

}
4

1 回答 1

1

我不确定这是问题所在,但我认为您应该从 splashUnjum() 中删除此行

this.mEngine.setScene(sceneUnjumSplash);

将对 splashUnjum() 的调用替换为

this.mEngine.setScene(splashUnjum());

您应该做的另一件事是确保更改发生在 updateThread

于 2012-04-11T16:26:42.030 回答