Open totallyeviljake opened 11 years ago
This may be a phenomenon of MonoGame.
This also happens on WP7. Open the game, click the windows button, note the onExit is not called. Resume the game (back button), note OnEnter is called.
The problem is from using CCDirector.ResumeFromBackground() which calls onEnter on the top scene when it is not a transition scene.
As you can see, the pause() method does not call OnExit, but the ResumeFromBackground does call OnEnter
public void Pause()
{
if (m_bPaused)
{
return;
}
m_dOldAnimationInterval = m_dAnimationInterval;
// when paused, don't consume CPU
AnimationInterval = 1 / 4.0;
m_bPaused = true;
}
public void ResumeFromBackground()
{
Resume();
if (m_pRunningScene != null)
{
bool runningIsTransition = m_pRunningScene is CCTransitionScene;
if (!runningIsTransition)
{
m_pRunningScene.OnEnter();
m_pRunningScene.OnEnterTransitionDidFinish();
}
}
}
Pause () terminates the call is shedule Update () only
Need a pair call, for example EnterToBackground, that would make a pause, and caused OnExit
the latest version of cocos2d-x is not ResumeFromBackground in CCDirector. but has ApplicationProtocol: applicationDidEnterBackground and applicationWillEnterForeground
ResumeFromBackground was added by me. It needs a balancing method, or to be removed. I forget why I added it and did not document why it was added.
When the game pauses, the current scene and its children do not receive an OnExit call. Yet, when the game resumes, the scene graph receives an OnEnter call. This causes an imbalance in any state that may change during OnEnter that would otherwise be balanced by OnExit.