cocos2dx进阶学习之CCSpriteBatchNode
来源:互联网 发布:淘宝客户端删除评价 编辑:程序博客网 时间:2024/05/21 16:23
继承关系
CCSpriteBatchNode -> CCNode, CCTextureProtocol
成员变量
inline CCTextureAtlas* getTextureAtlas(void)
inline void setTextureAtlas(CCTextureAtlas* textureAtlas)
获取/设置纹理图集,纹理图集是管理一张大图纹理和区域信息结构体
static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex, unsigned int capacity);
static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex) ;
static CCSpriteBatchNode* create(const char* fileImage, unsigned int capacity);
static CCSpriteBatchNode* create(const char* fileImage)
创建一个CCSpriteBatchNode对象
bool initWithTexture(CCTexture2D *tex, unsigned int capacity);
bool initWithFile(const char* fileImage, unsigned int capacity);
bool init();
初始化CCSpriteBatchNode对象
void increaseAtlasCapacity();
扩容
void removeChildAtIndex(unsigned int index, bool doCleanup);
删除一个精灵
void insertChild(CCSprite *child, unsigned int index);
void appendChild(CCSprite* sprite);
增加精灵
void removeSpriteFromAtlas(CCSprite *sprite);
将精灵从贴图集中删除
unsigned int rebuildIndexInOrder(CCSprite *parent, unsigned int index);
重构子节点索引
unsigned int highestAtlasIndexInChild(CCSprite *sprite);
unsigned int lowestAtlasIndexInChild(CCSprite *sprite);
unsigned int atlasIndexForChild(CCSprite *sprite, int z);
取得精灵对应的z轴下标
virtual CCTexture2D* getTexture(void);
virtual void setTexture(CCTexture2D *texture);
获取/设置纹理
virtual void setBlendFunc(ccBlendFunc blendFunc);
virtual ccBlendFunc getBlendFunc(void);
设置/获取混合函数
virtual void visit(void);
访问,重画节点
virtual void addChild(CCNode * child);
virtual void addChild(CCNode * child, int zOrder);
virtual void addChild(CCNode * child, int zOrder, int tag);
增加子精灵
virtual void reorderChild(CCNode * child, int zOrder);
virtual void removeChild(CCNode* child, bool cleanup);
virtual void removeAllChildrenWithCleanup(bool cleanup);
删除子精灵
virtual void sortAllChildren();
对精灵排序
virtual void draw(void);
绘制
总结
CCSpriteBatchNode是对一批相同纹理的精灵的封装,通过CCSpriteBatchNode封装之后,能提高渲染效率。
在实际工作中,精灵很多,而且很多精灵都是一样的,比如在飞机大战中,所有的子弹都是一样的,那么子弹就可以用CCSpriteBatchNode封装以提高效率。
- cocos2dx进阶学习之CCSpriteBatchNode
- cocos2dX 番外篇之CCSpriteBatchNode
- cocos2dx进阶学习之CCObject
- cocos2dx进阶学习之CCApplication
- cocos2dx进阶学习之CCEGLView
- cocos2dx进阶学习之CCDirector
- cocos2dx进阶学习之CCScene
- cocos2dx进阶学习之CCNode
- cocos2dx进阶学习之CCLayer
- cocos2dx进阶学习之CCSprite
- cocos2dx进阶学习之CCTMXTiledMap
- cocos2dx进阶学习之CCTMXLayer
- cocos2dx进阶学习之CCAction
- cocos2dx进阶学习之CCLayer
- cocos2dx进阶学习之CCNode
- cocos2dx进阶学习之CCNode
- cocos2dx进阶学习之CCDirector
- cocos2dx进阶学习之CCEGLView
- lamp环境搭建
- python27 mysql win7扩展安装 使用
- 基于Android平台的ToDoList APP
- MySql获取系统时间
- Linux的五个查找命令
- cocos2dx进阶学习之CCSpriteBatchNode
- ant build.xml中classpath
- Launcher 功能表中优先显示以指定字符串开头的包名的应用
- SpringMVC 前台提交不同类多个对象或同一类多个对象集合到后台
- 浏览器的加载与页面性能优化
- “大数据处理技术 - 基于Hadoop的实战”北上广三地热捧!
- 丁香园:得医生者得天下
- 【LeetCode】Triangle
- 二叉排序树增删改查