我在使用CSLoader::createNode的时候,深入代码发现,
在nodeWithFlatBuffersFile中
int textureSize = csparsebinary->textures()->size(); 获取到的textureSize为96,
如果我没理解错,这个size应该是我csb文件所对应的plist数量,因为下面的便利是读取plist的,
因此我想知道这里获取是96是为什么
代码如下
Node* CSLoader::nodeWithFlatBuffersFile(const std::string &fileName, const ccNodeLoadCallback &callback)
{
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
CC_ASSERT(FileUtils::getInstance()->isFileExist(fullPath));
Data buf = FileUtils::getInstance()->getDataFromFile(fullPath);
auto csparsebinary = GetCSParseBinary(buf.getBytes());
auto csBuildId = csparsebinary->version();
if (csBuildId)
{
CCASSERT(strcmp(_csBuildID.c_str(), csBuildId->c_str()) == 0,
String::createWithFormat("%s%s%s%s%s%s%s%s%s%s",
"The reader build id of your Cocos exported file(",
csBuildId->c_str(),
") and the reader build id in your Cocos2d-x(",
_csBuildID.c_str(),
") are not match.\n",
"Please get the correct reader(build id ",
csBuildId->c_str(),
")from ",
"http://www.cocos2d-x.org/filedown/cocos-reader",
" and replace it in your Cocos2d-x")->getCString());
}
// decode plist
auto textures = csparsebinary->textures();
int textureSize = csparsebinary->textures()->size();
CCLOG("textureSize = %d", textureSize);
for (int i = 0; i < textureSize; ++i)
{
SpriteFrameCache::getInstance()->addSpriteFramesWithFile(textures->Get(i)->c_str());
}
Node* node = nodeWithFlatBuffers(csparsebinary->nodeTree(), callback);
return node;
}
```
