1.众生相,皆精灵

2.精灵的类继承关系

class CCSprite : public CCNode, public CCNodeRGBA, public CCTextureProtocol

3.创建精灵的三大类方法

4.代码实现

/**
* Creates an empty sprite without texture. You can call setTexture method subsequently.
*
* @return An empty sprite object that is marked as autoreleased.
*/
1.1 static CCSprite* create(); /**
* Creates a sprite with an image filename.
*
* After creation, the rect of sprite will be the size of the image,
* and the offset will be (0,0).
*
* @param pszFileName The string which indicates a path to image file, e.g., "scene1/monster.png".
* @return A valid sprite object that is marked as autoreleased.
*/
1.2 static CCSprite* create(const char *pszFileName); /**
* Creates a sprite with an image filename and a rect.
*
* @param pszFileName The string wich indicates a path to image file, e.g., "scene1/monster.png"
* @param rect Only the contents inside rect of pszFileName's texture will be applied for this sprite.
* @return A valid sprite object that is marked as autoreleased.
*/
1.3 static CCSprite* create(const char *pszFileName, const CCRect& rect); /**
* Creates a sprite with an exsiting texture contained in a CCTexture2D object
* After creation, the rect will be the size of the texture, and the offset will be (0,0).
*
* @param pTexture A pointer to a CCTexture2D object.
* @return A valid sprite object that is marked as autoreleased.
*/
2.1 static CCSprite* createWithTexture(CCTexture2D *pTexture); /**
* Creates a sprite with a texture and a rect.
*
* After creation, the offset will be (0,0).
*
* @param pTexture A pointer to an existing CCTexture2D object.
* You can use a CCTexture2D object for many sprites.
* @param rect Only the contents inside the rect of this texture will be applied for this sprite.
* @return A valid sprite object that is marked as autoreleased.
*/
2.2 static CCSprite* createWithTexture(CCTexture2D *pTexture, const CCRect& rect); /**
* Creates a sprite with an sprite frame.
*
* @param pSpriteFrame A sprite frame which involves a texture and a rect
* @return A valid sprite object that is marked as autoreleased.
*/
3.1 static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); /**
* Creates a sprite with an sprite frame name.
*
* A CCSpriteFrame will be fetched from the CCSpriteFrameCache by pszSpriteFrameName param.
* If the CCSpriteFrame doesn't exist it will raise an exception.
*
* @param pszSpriteFrameName A null terminated string which indicates the sprite frame name.
* @return A valid sprite object that is marked as autoreleased.
*/
3.2 static CCSprite* createWithSpriteFrameName(const char *pszSpriteFrameName);

cocos2.2.3中创建精灵对象的三大类方法的更多相关文章

  1. 通常Struts框架会自动地从action mapping中创建action对象

    开发者不必在Spring中去注册action,尽管可以这么去做,通常Struts框架会自动地从action mapping中创建action对象 struts2-spring-plugin-x-x-x ...

  2. JavaScript中创建字典对象(dictionary)实例

    这篇文章主要介绍了JavaScript中创建字典对象(dictionary)实例,本文直接给出了实现的源码,并给出了使用示例,需要的朋友可以参考下 对于JavaScript来说,其自身的Array对象 ...

  3. 简单使用JSON,JavaScript中创建 JSON 对象(一)

    JSON:JavaScript 对象表示法(JavaScript Object Notation). JSON 是存储和交换文本信息的语法.类似 XML. JSON 比 XML 更小.更快,更易解析. ...

  4. SpriteBuilder中CCB精灵对象的Sprite frame为什么有时候不能修改

    有时候你会发现CCB中的精灵对象(root节点)的Sprite frame是灰色的,不能修改.因为它是根对象,所以不存在被嵌入其他CCB的情况,那到底是什么原因呢? 可以发现此时的Timeline当前 ...

  5. Java中创建实例化对象的几种方式

    Java中创建实例化对象有哪些方式? ①最常见的创建对象方法,使用new语句创建一个对象.②通过工厂方法返回对象,例:String s =String.valueOf().(工厂方法涉及到框架)③动用 ...

  6. Java中创建的对象多了,必然影响内存和性能

    1, Java中创建的对象多了,必然影响内存和性能,所以对象的创建越少越好,最后还要记得销毁.

  7. spring中创建bean对象的三种方式以及作用范围

    时间:2020/02/02 一.在spring的xml配置文件中创建bean对象的三种方式: 1.使用默认构造函数创建.在spring的配置文件中使用bean标签,配以id和class属性之后,且没有 ...

  8. 本地C代码中创建Java对象

    作者:唐老师,华清远见嵌入式学院讲师. 创建Java域的对象就是创建Java类的实例,再调用Java类的构造方法. 以Bitmap的构建为例,Bitmap中并没有Java对象创建的代码及外部能访问的构 ...

  9. R中创建not-yet-evaluated对象

    create not-yet-evaluated object在R中创建 not-yet-evaluated(就是some code we will evaluated later!!)对象;然后执行 ...

随机推荐

  1. Linux之cuda安装

    1.下载https://developer.nvidia.com/cuda-downloads 2.双击下载好的deb进行安装 3.sudo apt-get install cuda 4.As par ...

  2. 《JavaScript高级程序设计》笔记——关于继承

    继承在JavaScript中是一种“奇葩”的存在,因为其本身并没有类(class)的概念(ES5),所以只能用其他方式(原型链.构造函数.对象实例)来模拟继承的行为.既然是模拟,那就应该是想办法实现继 ...

  3. Log4.net使用配置

    开发中经常使用到日志记录功能,Log4.net可以将日志记录到文件中,也可以记录到数据库中,使用非常方便,之前也一直在用,最近也参照了一下网上的资料,想简单总结一下 本文重在通过通用日志类来使用Log ...

  4. [转] 利用任务计划重启sqlserver服务

    1.建立一个批处理文件restartsqlserver.bat     内容如下:     net   stop   mssqlserver   /y    net   start  mssqlser ...

  5. throws与throw的对比

    1.throws关键字通常被应用在声明方法时,用来指定可能抛出的异常.多个异常可以使用逗号隔开.当在主函数中调用该方法时,如果发生异常,就会将异常抛给指定异常对象.如下面例子所示:public cla ...

  6. iOS - UIView操作(SWift)

    1. UIView 视图的渐变填充 override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after ...

  7. 使用Struts2 验证框架,验证信息重复多次出现

    版权声明:本文为博主原创文章,未经博主允许不得转载. 问题描述:第一次提交表单.某个数据不符合规则,就会出现一条错误信息.再次提交,上次显示的错误信息不消失,又多出一条一模一样的错误信息.提交几次,就 ...

  8. XtraGrid使用心得(折叠式主细档、分组统计)

    XtraGrid的关键类就是:GridControl和GridView.GridControl本身不显示数据,数据都是显示在GridView/CardView/XXXXView中.GridContro ...

  9. 编程Tips

    三元运算符 Vb中的iif(expr,truepart,falsepart)和C#中的expr?truepart:falsepart. 无论expr的结果是true还是false,true/false ...

  10. 10款很酷的HTML5动画和实用应用 有源码

    10款很酷的HTML5动画和实用应用,这里有菜单.SVG动画.Loading动画,总有你喜欢的,而且,每一款HTML5应用都提供源代码下载,方便大家学习和研究,一起来看看吧. 1.HTML5 SVG ...