使用cocostudioUI编辑器制作的ui动画,在游戏中二次加载后播放动画直接死。。在cocochina上找到对应解决办法,记录一下
原帖地址:http://www.cocoachina.com/bbs/read.php?tid=213201
在cocos2d\cocos\editor-support\cocostudio文件夹下的CCActionManagerEx.h/.cpp文件中添加一个释放动作的函数
CCActionManagerEx.h :
/* Release all actions by jsonName.
*@param jsonName UI file name
*/
void releaseActionsByJsonName( const char* jsonName );
CCActionManagerEx.cpp :
void ActionManagerEx::releaseActionsByJsonName( const char* jsonName )
{
std::unordered_map<std::string, cocos2d::Vector<ActionObject*>>::iterator iter = _actionDic.find(jsonName);
if (iter != _actionDic.end())
{
cocos2d::Vector<ActionObject*> objList = iter->second;
for(const auto e : objList)
{
e->stop();
}
objList.clear();
_actionDic.erase(iter);
}
}
在释放ui的时候,调用上面释放动作的函数。