Пример #1
0
void CCDirector::popToRootScene(void)
{
    CCAssert(m_pRunningScene != NULL, "A running Scene is needed");
    unsigned int c = m_pobScenesStack->count();

    if (c == 1) 
    {
        m_pobScenesStack->removeLastObject();
        this->end();
    } 
    else 
    {
        while (c > 1) 
        {
            CCScene *current = (CCScene*)m_pobScenesStack->lastObject();
            if( current->isRunning() )
            {
                current->onExitTransitionDidStart();
                current->onExit();
            }
            current->cleanup();

            m_pobScenesStack->removeLastObject();
            c--;
        }
        m_pNextScene = (CCScene*)m_pobScenesStack->lastObject();
        m_bSendCleanupToScene = false;
    }
}
Пример #2
0
void CCDirector::popToSceneStackLevel(int level)
{
    CCAssert(m_pRunningScene != NULL, "A running Scene is needed");
    int c = (int)m_pobScenesStack->count();

    // level 0? -> end
    if (level == 0)
    {
        end();
        return;
    }

    // current level or lower -> nothing
    if (level >= c)
        return;

	// pop stack until reaching desired level
	while (c > level)
    {
		CCScene *current = (CCScene*)m_pobScenesStack->lastObject();

		if (current->isRunning())
        {
            current->onExitTransitionDidStart();
            current->onExit();
		}

        current->cleanup();
        m_pobScenesStack->removeLastObject();
		c--;
	}

	m_pNextScene = (CCScene*)m_pobScenesStack->lastObject();
	m_bSendCleanupToScene = false;
}