Skip to content

Instantly share code, notes, and snippets.

@darkfall
Created May 21, 2012 02:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save darkfall/2760319 to your computer and use it in GitHub Desktop.
Save darkfall/2760319 to your computer and use it in GitHub Desktop.
Cocos2dx PopScene with Transition
template<typename T>
void CCDirector::popSceneWithTransition(float t) {
CCAssert(m_pRunningScene != NULL, "running scene should not null");
m_pobScenesStack->removeLastObject();
unsigned int c = m_pobScenesStack->count();
if (c == 0) {
end();
}
else {
m_bSendCleanupToScene = true;
m_pNextScene = m_pobScenesStack->getObjectAtIndex(c - 1);
CCScene* trans = T::transitionWithDuration(t, m_pNextScene);
m_pobScenesStack->replaceObjectAtIndex(c-1, trans);
m_pNextScene = trans;
}
}
@fnc12
Copy link

fnc12 commented Oct 6, 2015

update code for cocos2d-x 3.0+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment