fixed ui anmation crash when stop animation

This commit is contained in:
Liam 2013-11-19 00:57:22 +08:00
parent b4671f4002
commit c7932b6181
4 changed files with 15 additions and 6 deletions

View File

@ -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()

View File

@ -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);

View File

@ -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)

View File

@ -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();