MCPcopy Create free account
hub / github.com/axmolengine/axmol / reset

Method reset

core/base/Director.cpp:1015–1117  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1013}
1014
1015void Director::reset()
1016{
1017#if AX_ENABLE_GC_FOR_NATIVE_OBJECTS
1018 auto sEngine = ScriptEngineManager::getInstance()->getScriptEngine();
1019#endif // AX_ENABLE_GC_FOR_NATIVE_OBJECTS
1020
1021 if (_runningScene)
1022 {
1023#if AX_ENABLE_GC_FOR_NATIVE_OBJECTS
1024 if (sEngine)
1025 {
1026 sEngine->releaseScriptObject(this, _runningScene);
1027 }
1028#endif // AX_ENABLE_GC_FOR_NATIVE_OBJECTS
1029 _runningScene->onExit();
1030
1031 // Ensure incoming scene is correctly deactivated if the
1032 // director is reset during a scene transition
1033 auto transition = dynamic_cast<TransitionScene*>(_runningScene);
1034 if (transition)
1035 transition->getInScene()->onExit();
1036
1037 _runningScene->cleanup();
1038 _runningScene->release();
1039 }
1040
1041 _runningScene = nullptr;
1042 _nextScene = nullptr;
1043
1044 if (_eventDispatcher)
1045 _eventDispatcher->dispatchEvent(_eventResetDirector);
1046
1047#if defined(AX_ENABLE_AUDIO)
1048 // Fix github issue: https://github.com/axmolengine/axmol/issues/550
1049 // !!!The AudioEngine hold scheduler must end before Director destroyed, otherwise, just lead app crash
1050 AudioEngine::end();
1051#endif
1052
1053 // cleanup scheduler
1054 getScheduler()->unscheduleAll();
1055
1056 // Remove all events
1057 if (_eventDispatcher)
1058 {
1059 _eventDispatcher->removeAllEventListeners();
1060 }
1061
1062 if (_notificationNode)
1063 {
1064 _notificationNode->onExit();
1065 _notificationNode->cleanup();
1066 _notificationNode->release();
1067 }
1068
1069 _notificationNode = nullptr;
1070
1071 // remove all objects, but don't release it.
1072 // runWithScene might be executed after 'end'.

Callers

nothing calls this directly

Calls 11

getInstanceFunction · 0.85
popBackMethod · 0.80
getSchedulerFunction · 0.70
endFunction · 0.50
onExitMethod · 0.45
cleanupMethod · 0.45
releaseMethod · 0.45
dispatchEventMethod · 0.45
unscheduleAllMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected