首页 > 代码库 > cocos2d-x的popScene的动画效果

cocos2d-x的popScene的动画效果

找到CCDirector.h,找到void popScene();

在下面加上一段类模板

template <class T>void popSceneWithTransition(float t){    CCASSERT(_runningScene != nullptr, "running scene should not null");    _scenesStack.popBack();    ssize_t c = _scenesStack.size();    if (c == 0)    {        end();    }    else    {        _sendCleanupToScene = true;        Scene* scene = T::create(t, _scenesStack.at(c - 1));        _scenesStack.replace(c - 1, scene);        _nextScene = scene;    }}

 

在需要调用的地方,一句话

Director::getInstance()->popSceneWithTransition<TransitionFade>(1.0);

常用的Transition应该都可以用