diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp index 68c02fed95..03528ce8d2 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.cpp +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.cpp @@ -95,13 +95,14 @@ ActionObject* ActionManagerEx::getActionByName(const char* jsonName,const char* return NULL; } -void ActionManagerEx::playActionByName(const char* jsonName,const char* actionName) +ActionObject* ActionManagerEx::playActionByName(const char* jsonName,const char* actionName) { ActionObject* action = getActionByName(jsonName,actionName); if (action) { action->play(); } + return action; } void ActionManagerEx::releaseActions() diff --git a/cocos/editor-support/cocostudio/CCActionManagerEx.h b/cocos/editor-support/cocostudio/CCActionManagerEx.h index 09d62b10b6..3e5bb8511c 100644 --- a/cocos/editor-support/cocostudio/CCActionManagerEx.h +++ b/cocos/editor-support/cocostudio/CCActionManagerEx.h @@ -72,8 +72,10 @@ public: * @param jsonName UI file name * * @param actionName action name in teh UIfile. + * + * @return ActionObject which named as the param name */ - void playActionByName(const char* jsonName,const char* actionName); + ActionObject* playActionByName(const char* jsonName,const char* actionName); /*init properties with json dictionay*/ void initWithDictionary(const char* jsonName,JsonDictionary* dic,cocos2d::Object* root); diff --git a/cocos/editor-support/cocostudio/CCActionObject.cpp b/cocos/editor-support/cocostudio/CCActionObject.cpp index 5749a808dd..58a2155086 100644 --- a/cocos/editor-support/cocostudio/CCActionObject.cpp +++ b/cocos/editor-support/cocostudio/CCActionObject.cpp @@ -41,15 +41,15 @@ ActionObject::ActionObject() { _actionNodeList = Array::create(); _actionNodeList->retain(); - _pScheduler = new Scheduler(); - Director::getInstance()->getScheduler()->scheduleUpdateForTarget(_pScheduler, 0, false); + _pScheduler = Director::getInstance()->getScheduler(); + CC_SAFE_RETAIN(_pScheduler); } ActionObject::~ActionObject() { _actionNodeList->removeAllObjects(); _actionNodeList->release(); - CC_SAFE_DELETE(_pScheduler); + CC_SAFE_RELEASE(_pScheduler); } void ActionObject::setName(const char* name) diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp index 1af3b06657..3f3a56f573 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioSceneTest/SceneEditorTest.cpp @@ -60,6 +60,8 @@ bool SceneEditorTestLayer::init() return bRet; } +static ActionObject* actionObject = nullptr; + cocos2d::Node* SceneEditorTestLayer::createGameScene() { Node *pNode = SceneReader::getInstance()->createNodeWithSceneFile("scenetest/FishJoy2.json"); @@ -79,12 +81,16 @@ cocos2d::Node* SceneEditorTestLayer::createGameScene() pNode->addChild(menuBack); //ui action - ActionManagerEx::shareManager()->playActionByName("startMenu_1.json","Animation1"); + actionObject = ActionManagerEx::shareManager()->playActionByName("startMenu_1.json","Animation1"); return pNode; } void SceneEditorTestLayer::toExtensionsMainLayer(cocos2d::Object *sender) { + if (actionObject) + { + actionObject->stop(); + } ComAudio *pBackMusic = (ComAudio*)(_curNode->getComponent("CCBackgroundAudio")); pBackMusic->stopBackgroundMusic(); ExtensionsTestScene *pScene = new ExtensionsTestScene();