diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp index cf650bc7e2..76a15e0bba 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp @@ -42,7 +42,12 @@ ActionManagerEx* ActionManagerEx::getInstance() void ActionManagerEx::destroyInstance() { - CC_SAFE_DELETE(sharedActionManager); + if(sharedActionManager != nullptr) + { + sharedActionManager->releaseActions(); + CC_SAFE_DELETE(sharedActionManager); + } + } ActionManagerEx::ActionManagerEx() @@ -154,6 +159,13 @@ void ActionManagerEx::releaseActions() for (iter = _actionDic.begin(); iter != _actionDic.end(); iter++) { cocos2d::Vector objList = iter->second; + int listCount = objList.size(); + for (int i = 0; i < listCount; i++) { + ActionObject* action = objList.at(i); + if (action != nullptr) { + action->stop(); + } + } objList.clear(); } diff --git a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 0d6931120d..ebc3dcb8e6 100644 --- a/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/tests/cpp-tests/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -277,6 +277,7 @@ cocos2d::Node* LoadSceneEdtiorFileTest::createGameScene() { _filePath = "scenetest/LoadSceneEdtiorFileTest/FishJoy2.json"; //default is json _rootNode = SceneReader::getInstance()->createNodeWithSceneFile(_filePath.c_str()); + ActionManagerEx::getInstance()->playActionByName("startMenu_1.json", "Animation1"); if (_rootNode == nullptr) { return nullptr;