cocos2dx进阶学习之CCSpriteBatchNode
继承关系
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进阶学习之场景切换
背景 在学习马里奥时,我们学习到从菜单场景到游戏场景的切换,代码如下 void CMMenuScene::OnStartCallBack( CCObject *pSender ) { CCDirect ...
- cocos2dx进阶学习之CCSprite
继承关系 CCSprite -> CCNodeRGBA -> CCNode, CCRGBAProtocol CCTextureProtocol 从继承关系可以看出,CCSp ...
- cocos2dx进阶学习之CCScene
继承关系 CCScene -> CCNode -> CCObject CCScene抽象了一个场景的概念,类似舞台的一幕 函数 static CCScene *create(void); ...
- cocos2dx进阶学习之屏幕适配
背景 在学习cocos2dx时,我们在main函数中发现一句代码, #include "main.h" #include "AppDelegate.h" #in ...
- cocos2dx进阶学习之CCEGLView
继承关系 CCEGLView-> CCEGLViewProtocol CCEGLView是窗口,在不同平台上有不同的实现,而CCEGLViewProtocol是CCEGLView定义的接口,所以 ...
- cocos2dx进阶学习之CCAction
CCAction在cocos2dx中,抽象了节点的动作.它由CCObject派生,因此它不是渲染节点. 它经常的用法是,创建一个action,然后让某个CCNode对象(一般是精灵),去执行它. 在马 ...
- cocos2dx进阶学习之瓦片地图编辑器
之前学习了瓦片地图类,现在我们来学习下瓦片地图制作工具 这个是开源的工具,可以从网上下载,下面我们演示下怎么做地图 步骤1 将需要用到的图片放到一个目录下,比如我机器上就是d:\tiled,这些图片是 ...
- cocos2dx进阶学习之CCTMXLayer
继承关系 CCTMXLayer -> CCSpriteBatchNode CCTMXLayer是在瓦片地图中,抽象一个层的类,它继承自CCSpriteBatchNode,也就是说它抽象了一批相同 ...
- cocos2dx进阶学习之CCTMXTiledMap
继承关系 CCTMXTiledMap -> CCNode 它由CCNode派生,我们已经知道CCNode是cocos2dx的舞台对象的公共父类,所以CCTMXTiledMap也是个舞台对象 成员 ...
随机推荐
- angularJS使用$watch监控数据模型的变化
使用$watch监控数据模型的变化 在scope 内置的全部函数中,用得最多的可能就是$watch 函数了.当你的数据模型中某一部分发生变化时,$watch 函数能够向你发出通知.你能够监控单个对象的 ...
- Node.js笔记1
Node.js入门笔记 1. node -help 可以显示帮助信息2. node REPL 模式(Read-eval-print loop) 输入—求值—输出循环 直接在cmd输入node 可以进入 ...
- 在unity 脚本中获取客户端的IP地址
需要using System.Net.NetworkInformation;原理就是获取网卡的信息. //下面这段代码是我在百度贴吧找来的,经检验是正确的 string userIp = " ...
- js中Date对象
Date常用的几个方法: var oDate=new Date(); oDate.getHours()方法是获取当前的小时 oDate.getMinutes()方法获取当前的分钟 oDate.getS ...
- redis在java项目中的使用
在上一篇文章中已经讲了redis的spring配置,这篇将会描述redis在java项目中的使用. redis存储形式都是key-value(键值对),按照存储的内容分为两种,一种是存简单数据,即数字 ...
- java读取配置文件的几种方法
java读取配置文件的几种方法 原文地址:http://hbcui1984.iteye.com/blog/56496 在现实工作中,我们常常需要保存一些系统配置信息,大家一般都会选择配 ...
- Find the k-th Smallest Element in the Union of Two Sorted Arrays
(http://leetcode.com/2011/01/find-k-th-smallest-element-in-union-of.html) Given two sorted arrays A, ...
- Android应用开发基础篇(15)-----URL(获取指定网址里的图片)
链接地址:http://www.cnblogs.com/lknlfy/archive/2012/03/10/2389190.html 一.概述 URL,说白了就是一个网络地址(网址),通常一个网址里包 ...
- KMP算法的一次理解
1. 引言 在一个大的字符串中对一个小的子串进行定位称为字符串的模式匹配,这应该算是字符串中最重要的一个操作之一了.KMP本身不复杂,但网上绝大部分的文章把它讲混乱了.下面,咱们从暴力匹配算法讲起,随 ...
- .net 基础错误-string.replace 方法
1.string string.Replace(string oldValue,string newValue) 返回一个新的字符串,其中当前示例中出现的所有指定字符串都替换另一个指定字符串 错误:总 ...