When does OnExitTransitionDidStart occur?

I’ve been looking around sample code and I noticed 4 callbacks: OnEnter, OnExit, OnEnterTransitionDidFinish, and OnExitTransitionDidStart. I am replacing scenes with transitions like this:

CCScene* pScene = CCTransitionFade::transitionWithDuration(1.5f, OpeningSequenceLogo::scene()); if (pScene) { CCDirector::sharedDirector()->replaceScene(pScene); }

Only the first 3 get called though. When does OnExitTransitionDidStart occur?

Right, It doesn’t work for me either.

The problem seems to be in Transition.cpp

On exit, CCDirector::setNextScene code does:

if (m_pRunningScene)
{
   m_pRunningScene->onExitTransitionDidStart();
   m_pRunningScene->onExit();
}

OnExit is overriden in CCTransitionScene, as you can see:
(here is where the 3 methods that get called are actually called)

// custom onEnter
void CCTransitionScene::onEnter()
{
    CCScene::onEnter();
    m_pInScene->onEnter();
    // outScene should not receive the onEnter callback
}

// custom onExit
void CCTransitionScene::onExit()
{
    CCScene::onExit();
    m_pOutScene->onExit();

    // inScene should not receive the onExit callback
    // only the onEnterTransitionDidFinish
    m_pInScene->onEnterTransitionDidFinish();
}

But onExitTransitionDidStart is not overriden in CCTransitionScene.
So, the call in CCDirector falls to CCNode, which has no relation with the outgoing scene, whose onExitTransitionDidStart is never called.

Maybe the method CCTransitionScene::onEnter() should be modifies to also call the onExitTransitionDidStart of the outgoing scene like

m_pOutScene->onExitTransitionDidStart

Is any cocos2d-x developer able to confirm this?

Hi,

It’s very strange that the issue is still here (v2.1.1).
As result the common workflow of nodes is violated. I’d consider it as a high-priority bug.

Please, let me know if I’m wrong.

I hope the solution from Ardhan S will be put to cocos2d-x.

Thanks.

I don’t think cocos2d-x developers are reading all threads here but this bug is already reported on github https://github.com/cocos2d/cocos2d-x/issues/1450 so you can also send a comment there.

Leszek Leszek wrote:

I don’t think cocos2d-x developers are reading all threads here but this bug is already reported on github https://github.com/cocos2d/cocos2d-x/issues/1450 so you can also send a comment there.

It’s a very good point. :slight_smile:
Thank you for the link.