CSLader加载plist
来源:互联网 发布:知乐小说作品集百度云 编辑:程序博客网 时间:2024/06/07 02:36
Node* CSLoader::createNode(const std::string& filename){ std::string path = filename; size_t pos = path.find_last_of('.'); std::string suffix = path.substr(pos + 1, path.length()); CSLoader* load = CSLoader::getInstance(); if (suffix == "csb") { return load->createNodeWithFlatBuffersFile(filename); } else if (suffix == "json" || suffix == "ExportJson") { return load->createNodeFromJson(filename); } return nullptr;}Node* CSLoader::createNodeWithFlatBuffersFile(const std::string &filename, const ccNodeLoadCallback &callback){ Node* node = nodeWithFlatBuffersFile(filename, callback); reconstructNestNode(node); return node;}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); if (buf.isNull()) { CCLOG("CSLoader::nodeWithFlatBuffersFile - failed read file: %s", fileName.c_str()); CC_ASSERT(false); return nullptr; } auto csparsebinary = GetCSParseBinary(buf.getBytes()); auto csBuildId = csparsebinary->version(); if (csBuildId) { CCASSERT(strcmp(_csBuildID.c_str(), csBuildId->c_str()) == 0, StringUtils::format("%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").c_str()); } // decode plist auto textures = csparsebinary->textures(); int textureSize = textures->size(); for (int i = 0; i < textureSize; ++i) { SpriteFrameCache::getInstance()->addSpriteFramesWithFile(textures->Get(i)->c_str()); } Node* node = nodeWithFlatBuffers(csparsebinary->nodeTree(), callback); return node;}
可以看出来,会加载plist中用到的图片到SpriteFrameCache中的。
阅读全文
0 0
- CSLader加载plist
- 加载plist播放特效
- NSBundle 加载 .plist文件
- 加载.plist中的汉字
- 加载plist数据
- cococs2d-x 多线程加载plist
- cococs2d-x 多线程加载plist
- cococs2d-x 多线程加载plist
- cococs2d-x 多线程加载plist
- 加载JSON文件,Plist文件
- 加载plist文件的过程
- 加载plist到模型数组
- iOS oc加载plist数据
- cocos-Lua加载plist文件
- cocos2dx中的内存加载PLIST
- 字典转模型&加载xib&加载plist
- 加载plist数据和懒加载
- Apple Sample代码摘抄-plist文件加载
- JAVA web 项目启动报 Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
- Java读取文件完整代码
- C# 彻底删除文件或目录,不可恢复,文件清除工具
- 零基础学python途中遇到的这些小问题——小更新笔记
- 判断app是否运行于前台的两个方法
- CSLader加载plist
- linux命令下载和安装
- mybatis解决字段名与实体类属性名不相同的冲突
- 通过 jQuery,对 CSS 元素进行操作。
- 命名函数表达式笨拙的作用域
- 深度拷贝和浅度拷贝
- jQuery中Ajax调用后台接口
- Android简单实现 缓存数据
- Android drawable layer-list