SpriteFrameCache
来源:互联网 发布:linux dd u盘启动盘 编辑:程序博客网 时间:2024/05/16 06:24
class CC_DLL SpriteFrameCache : public Ref{public: /** Adds multiple Sprite Frames from a plist file. * A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png. * If you want to use another texture, you should use the addSpriteFramesWithFile(const std::string& plist, const std::string& textureFileName) method. * @js addSpriteFrames * @lua addSpriteFrames * * @param plist Plist file name. */ void addSpriteFramesWithFile(const std::string& plist);}void SpriteFrameCache::addSpriteFramesWithFile(const std::string& plist){ CCASSERT(plist.size()>0, "plist filename should not be nullptr"); std::string fullPath = FileUtils::getInstance()->fullPathForFilename(plist); if (fullPath.size() == 0) { // return if plist file doesn't exist CCLOG("cocos2d: SpriteFrameCache: can not find %s", plist.c_str()); return; } if (_loadedFileNames->find(plist) == _loadedFileNames->end()) { ValueMap dict = FileUtils::getInstance()->getValueMapFromFile(fullPath); string texturePath(""); if (dict.find("metadata") != dict.end()) { ValueMap& metadataDict = dict["metadata"].asValueMap(); // try to read texture file name from meta data texturePath = metadataDict["textureFileName"].asString(); } if (!texturePath.empty()) { // build texture path relative to plist file texturePath = FileUtils::getInstance()->fullPathFromRelativeFile(texturePath.c_str(), plist); } else { // build texture path by replacing file extension texturePath = plist; // remove .xxx size_t startPos = texturePath.find_last_of("."); texturePath = texturePath.erase(startPos); // append .png texturePath = texturePath.append(".png"); CCLOG("cocos2d: SpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); } Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(texturePath.c_str()); if (texture) { addSpriteFramesWithDictionary(dict, texture); _loadedFileNames->insert(plist); } else { CCLOG("cocos2d: SpriteFrameCache: Couldn't load texture"); } }}
0 0
- SpriteFrameCache
- TextureCache SpriteFrameCache
- cocos2d-x3.0 SpriteFrameCache
- 使用SpriteFrameCache创建精灵
- SpriteFrameCache精灵框使用
- cocos2d-x SpriteFrameCache
- spriteFrameCache,AnimationCache,TextureCache
- SpriteFrameCache的注意事项
- spriteFrameCache和textureCache
- cocos2d-x SpriteFrameCache/TextureCache/AnimationCache
- -SpriteBatchNode与SpriteFrameCache加快渲染
- SpriteBatchNode与SpriteFrameCache加快渲染
- SpriteFrameCache遇到的函数问题
- Cocos2d-x SpriteFrameCache的使用
- SpriteBatchNode与SpriteFrameCache加快渲染
- [cocos2d-x]TextureCache和spriteFramecache
- Sprite和SpriteFrameCache的使用
- 【cocos2d-x3.5】Lua Plist与SpriteFrameCache
- TCP与UDP的区别
- 特权级2——不通过调用门
- PCB双面贴片如何过回流焊(硬件工程师应该了解一下)
- VS2010/MFC编程入门之四十五(MFC常用类:CFile文件操作类)
- 【移动端兼容问题研究】javascript事件机制详解(涉及移动兼容)
- SpriteFrameCache
- flask+mod_wsgi+apache在windows上的布署
- android 代码混淆
- android6.0是否获取到权限和运行时请求权限
- 特权级3——调用门
- Android 7.0 API 概述
- 今天发现了一篇介绍Sqoop中通过hadoop mapreduce从关系型数据库import数据分析
- Object方法
- iOS开发技能一览图