mirror of https://github.com/axmolengine/axmol.git
fixed ui anmation crash when stop animation
This commit is contained in:
parent
b4671f4002
commit
c7932b6181
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue