在CSLoader加载解析.csb文件中
Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree *nodetree, const ccNodeLoadCallback &callback)
这个函数里面解析“ProjectNode”这个时,(也就是嵌套子节点),动画解析时没有调用clone(),如果一个场景中同时嵌套多个同样
的动画,后面的就会将前面的覆盖掉,因为没有克隆
if (classname == "ProjectNode")
{
auto reader = ProjectNodeReader::getInstance();
auto projectNodeOptions = (ProjectNodeOptions*)options->data();
std::string filePath = projectNodeOptions->fileName()->c_str();
CCLOG("filePath = %s", filePath.c_str());
cocostudio::timeline::ActionTimeline* action = nullptr;
if (filePath != "" && FileUtils::getInstance()->isFileExist(filePath))
{
Data buf = FileUtils::getInstance()->getDataFromFile(filePath);
node = createNode(buf, callback);
//这里没有调用clone()函数,是直接拿缓存中的
action = timeline::ActionTimelineCache::getInstance()->loadAnimationWithDataBuffer(buf, filePath);
}
else
{
node = Node::create();
}
reader->setPropsWithFlatBuffers(node, options->data());
if (action)
{
action->setTimeSpeed(projectNodeOptions->innerActionSpeed());
node->runAction(action);
action->gotoFrameAndPause(0);
}
}