Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume calls OnEnter but not balanced with OnExit #273

Open
totallyeviljake opened this issue Aug 1, 2013 · 8 comments
Open

Resume calls OnEnter but not balanced with OnExit #273

totallyeviljake opened this issue Aug 1, 2013 · 8 comments

Comments

@totallyeviljake
Copy link
Member

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.

@totallyeviljake
Copy link
Member Author

This may be a phenomenon of MonoGame.

@totallyeviljake
Copy link
Member Author

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.

@totallyeviljake
Copy link
Member Author

The problem is from using CCDirector.ResumeFromBackground() which calls onEnter on the top scene when it is not a transition scene.

@totallyeviljake
Copy link
Member Author

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();
            }
        }
    }

@gena-m
Copy link
Member

gena-m commented Aug 1, 2013

Pause () terminates the call is shedule Update () only

@gena-m
Copy link
Member

gena-m commented Aug 1, 2013

Need a pair call, for example EnterToBackground, that would make a pause, and caused OnExit

@gena-m
Copy link
Member

gena-m commented Aug 1, 2013

the latest version of cocos2d-x is not ResumeFromBackground in CCDirector.
but has ApplicationProtocol: applicationDidEnterBackground and applicationWillEnterForeground

@totallyeviljake
Copy link
Member Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants