本文来自http://blog.csdn.net/runaying ,引用必须注明出处!
cocos2d-X 节点(CCSprite.h)API
温馨提醒:
为了大家能更好学习,强烈推荐大家看看本人的这篇博客 Cocos2d-X权威指南笔记
Sprite 是一个 2d 图片
1.更新 Sprite 的 texture、设置 sprite 的批处理节点、设置 sprite 在 TextureAtlas 里面的索引…
1.更新 Sprite 的 texture、设置 sprite 的批处理节点、设置 sprite 在 TextureAtlas 里面的索引…
///cocos2d-x-3.0alpha0/cocos2dx/sprite_nodes#ifndef __SPITE_NODE_CCSPRITE_H__
#define __SPITE_NODE_CCSPRITE_H__#include "base_nodes/CCNode.h"
#include "CCProtocols.h"
#include "textures/CCTextureAtlas.h"
#include "ccTypes.h"
#include "cocoa/CCDictionary.h"
#include <string>
#ifdef EMSCRIPTEN
#include "base_nodes/CCGLBufferedNode.h"
#endif // EMSCRIPTEN
#include "physics/CCPhysicsBody.h"NS_CC_BEGINclass SpriteBatchNode;
class SpriteFrame;
class Animation;
class Rect;
class Point;
class Size;
class Texture2D;
struct transformValues_;
简要
/*** @addtogroup sprite_nodes* @{*//** * Sprite 是一个 2d 图片 ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )** Sprite 可以使用一个图片,或者一个图片的子矩形创建** 如果 Parent 或任何其父类是一个 SpriteBatchNode,那么下面 features/limitations 是有效的 //功能/限制* - parent 是一个 BatchNode 时有一下特点:* - 更快的渲染,特别是 SpriteBatchNode 有许多 children 。所有的 children 都将被绘制在一批次里。** - Limitations* - Camera 不支持 (eg: OrbitCamera 动作不工作)* - GridBase动作不支持 (eg: Lens, Ripple, Twirl) //镜头,波纹,捻* - Alias/Antialias 属性属于到SpriteBatchNode,所以你不能单独设置别名属性。 //锯齿/消除锯齿* - Blending 功能属性属于SpriteBatchNode的,所以你不能单独设置混合功能属性。 //混合* - 滚动条视差,不支持,但可以使用 sprite 模拟“代替”** 如果 parent 是一个标准 Node, 那么精灵的表现方式和其它的节点一样;* - 支持混合功能* - 支持锯齿/抗锯齿* - 但渲染速度会变慢:每一次只能绘制一个 children。But the rendering will be slower: 1 draw per children.** Sprite 的默认锚点是 (0.5, 0.5).*/
class CC_DLL Sprite : public NodeRGBA, public TextureProtocol
#ifdef EMSCRIPTEN
, public GLBufferedNode
#endif // EMSCRIPTEN
{
public:static const int INDEX_NOT_INITIALIZED = -1; /// Sprite 索引在 SpriteBatchNode 上无效
创建初始化
/// @{/// @name Creators/*** 使用 texture 闯将一个空的 sprite , 你可以随后调用 setTexture 方法** @return 一个空的Sprite对象被标记为自动释放。*/static Sprite* create();/*** 使用一个图片名创建一个 sprite ** 创建后,矩形是 sprite 图像的大小,* 偏移量将是(0,0)。** @param 文件名的字符串表明了图片的路径, e.g., "scene1/monster.png".* @