我在ANDENGINE中有两项活动。一个是ACT_1,第二个是ACT_2。现在,我的ACT_1是一个呼叫ACT_2的呼叫者活动。
ACT_1是我的SplashScreen Loader活动。现在从ACT_1调用ACT_2后,我加载了一些资源和声音。它的工作正常。现在有一种状态,当有呼叫时,声音/音乐应停止,但活动的其他状态应保持不变。例如,如果acitvity是关于某些益智游戏,那么随叫随到的益智游戏状态保持不变,声音应暂停并在gameresume上恢复。我在ACT_2中尝试了OnPauseGame和OnResumeGame,但它在ACT_2中不起作用。但是当我在ACt_1中调用OnResume和OnPause时,它会调用这些函数。但问题是我的ACT_2再次开始。
ACT_1活动:
public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws Exception {
ACT_2 = new PUZZLE(this, this.mEngine, this.mCamera);
ACT_2.loadSplashSceneResources();
con=this.getApplicationContext();
pOnCreateResourcesCallback.onCreateResourcesFinished();
}
public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws Exception {
pOnCreateSceneCallback.onCreateSceneFinished(eating.createSplashScene());
}
public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
// TODO Auto-generated method stub
mEngine.registerUpdateHandler(new TimerHandler(1f, new ITimerCallback() {
public void onTimePassed(final TimerHandler pTimerHandler) {
mEngine.unregisterUpdateHandler(pTimerHandler);
ACT_2.loadGameSceneResources();
ACT_2.createGameScenes();
ACT_2.setCurrentScene();
}
}));
pOnPopulateSceneCallback.onPopulateSceneFinished();
}
@Override
public void onResumeGame() {
Log.i("herewwwww","Resume");
super.onResumeGame();
//super.mEngine.start();
//super.mEngine.getMusicManager().setMasterVolume(16);
//super.mEngine.getMusicManager().setMasterVolume(16);
Log.i("Volu",""+super.mEngine.getMusicManager().getMasterVolume());
}
@Override
public void onPauseGame() {
Log.i("herewwwww","Pause");
super.onPauseGame();
//finish();
}
ACT_2
public void onResumeGame() {
Log.i("act_2","resume");
activity.onResumeGame();
this.engine.start();
if(!back_music.isPlaying())
back_music.play();
}
public void onPauseGame() {
Log.i("act_2","pause");
activity.onPauseGame();
if(back_music.isPlaying())
back_music.pause();
}