SpriteFrameCache和SpriteBatchNode
2014-07-22 22:19
393 查看
Cocos2d中SpriteFrameCache通常用来处理plist文件,并能与SpriteBatchNode结合使用来达到批处理渲染精灵的目的。1)精灵帧缓存类SpriteFrameCache 2)精灵帧缓存类SpriteFrameCache 用来存储精灵帧,缓存精灵帧有助于提高程序的效率。 SpriteFrameCache是一个单例模式,不属于某个精灵,是所有精灵共享使用的。3)精灵批处理节点SpriteBatchNode 当你需要渲染显示两个或两个以上相同的精灵时,如果逐个渲染精灵,每一次渲染都会调用 OpenGL ES 的 draw 函数,这样做自然降低了渲染效率。不过幸好,Cocos2d为开发者提供了一个SpriteBatchNode类,它能一次渲染多个精灵。并可以用来批处理这些精灵。 在init()方法中调用SpriteFrameCache的addSpriteFramesWithFile方法,传入plist文件名称,它会从plist属性列表文件的元数据部分获取各个纹理的纹理名,载入到纹理缓存中。并解析属性列表文件,使用SpriteFrame对象来内部地跟踪所有精灵的信息。 在Cocos2d中高效使用图片总结:使用TexturePacker打包图片成pvr.ccz文件,使用SpriteBatchNode优化绘制,使用SpriteFrameCache缓存读取,使用spriteWithFrameName获取单张图片。
相关文章推荐
- cocos2d-SpriteBatchNode与SpriteFrameCache加快渲染的优缺点
- cocos2dx-3.0(13)------SpriteBatchNode与SpriteFrameCache加快渲染
- cocos2dx-3.0(14)------SpriteBatchNode与SpriteFrameCache加快渲染
- SpriteBatchNode与SpriteFrameCache加快渲染
- 【Cocos2dx 3.3 Lua】SpriteBatchNode和SpriteFrameCache使用
- -SpriteBatchNode与SpriteFrameCache加快渲染
- cocos2dx-3.0(14)------SpriteBatchNode与SpriteFrameCache加快渲染
- SpriteBatchNode与SpriteFrameCache加快渲染
- cocos2dx-3.0(13)------SpriteBatchNode与SpriteFrameCache加快渲染
- cocos2dx-3.0(13)------SpriteBatchNode与SpriteFrameCache渲染速度
- cocos2d-x 详解之 CCSprite(精灵)- “CCSpriteBatchNode”和“CCSpriteFrameCache”
- cocos2d-x 详解之 CCSprite(精灵)- “CCSpriteBatchNode”和“CCSpriteFrameCache”
- cocos2dx CCTextureCache 、CCSpriteBatchNode 、CCSpriteFrameCache区别
- 第二节,CCSpriteBatchNode CCSpriteFrameCache
- 预加载+CCSpriteBatchNode + CCSpriteFrameCache
- 第二节,CCSpriteBatchNode CCSpriteFrameCache
- 关于CCSprite、CCSpriteFrame、 CCSpriteFrameCache以及CCSpriteBatchNode的关系
- CCSpriteFrameCache和CCSpriteBatchNode
- CCSpriteBatchNode和CCSpriteFrameCache的区别及用法
- 预加载+CCSpriteBatchNode + CCSpriteFrameCache