Ive been trying to get my app to change from one scene to another. what i do is onLoadScene() i direct it to a method which has a scene, and what im trying to do is to set another scene which is in another method… but what i get is the sprite from the first scene stuck on the screen !
can someone help me in teaching me how to change from one scene to another in the same class.
here are my codes:
@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;
}
I’m not sure this is the issue, but I think you should remove this line from splashUnjum()
replace the call to splashUnjum() with
One other thing you should do is insure that the change happens on the updateThread