| 68 | } |
| 69 | |
| 70 | bool TransitionScene::initWithDuration(float t, Scene* scene) |
| 71 | { |
| 72 | AXASSERT(scene != nullptr, "Argument scene must be non-nil"); |
| 73 | |
| 74 | if (Scene::init()) |
| 75 | { |
| 76 | _duration = t; |
| 77 | |
| 78 | // retain |
| 79 | #if AX_ENABLE_GC_FOR_NATIVE_OBJECTS |
| 80 | auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine(); |
| 81 | if (sEngine) |
| 82 | { |
| 83 | sEngine->retainScriptObject(this, scene); |
| 84 | } |
| 85 | #endif // AX_ENABLE_GC_FOR_NATIVE_OBJECTS |
| 86 | _inScene = scene; |
| 87 | _inScene->retain(); |
| 88 | _outScene = _director->getRunningScene(); |
| 89 | if (_outScene == nullptr) |
| 90 | { |
| 91 | _outScene = Scene::create(); |
| 92 | // just change its state is running that can run actions later |
| 93 | // issue: https://github.com/cocos2d/cocos2d-x/issues/17442 |
| 94 | _outScene->onEnter(); |
| 95 | } |
| 96 | _outScene->retain(); |
| 97 | |
| 98 | AXASSERT(_inScene != _outScene, "Incoming scene must be different from the outgoing scene"); |
| 99 | |
| 100 | sceneOrder(); |
| 101 | |
| 102 | return true; |
| 103 | } |
| 104 | else |
| 105 | { |
| 106 | return false; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | void TransitionScene::sceneOrder() |
| 111 | { |