cocos2d-x 动画详解之三CCSpriteFrame
CCSpriteFrame
精灵帧
默认的构造方法
通过 图片纹理+纹理上的矩形来创建
或通过 图片纹理+纹理上的矩形+是否旋转+偏移坐标+真实size
这里简单讲下
是否旋转
为了节省图片空间 图片将会被旋转90度
偏移坐标+真实size
为了节省图片空间 原始图片周围透明区域将被trim
Public Member Functions |
|
constCCRect& | getRectInPixels(void) |
void | setRectInPixels(constCCRect&rectInPixels) |
bool | isRotated(void) |
void | setRotated(bool bRotated) |
constCCRect& | getRect(void) |
get rect of the frame | |
void | setRect(constCCRect&rect) |
set rect of the frame | |
constCCPoint& | getOffsetInPixels(void) |
get offset of the frame | |
void | setOffsetInPixels(constCCPoint&offsetInPixels) |
set offset of the frame | |
constCCSize& | getOriginalSizeInPixels(void) |
get original size of the trimmed image | |
void | setOriginalSizeInPixels(constCCSize&sizeInPixels) |
set original size of the trimmed image | |
CCTexture2D* | getTexture(void) |
get texture of the frame | |
void | setTexture(CCTexture2D*pobTexture) 设置图片纹理 |
set texture of the frame, the texture is retained | |
~CCSpriteFrame(void) | |
virtualCCObject* | copyWithZone(CCZone*pZone) |
bool | initWithTexture(CCTexture2D*pobTexture, constCCRect&rect) |
Initializes aCCSpriteFramewith a texture, rect in points. | |
bool | initWithTexture(CCTexture2D*pobTexture, constCCRect&rect, bool rotated, constCCPoint&offset, constCCSize&originalSize) |
Initializes aCCSpriteFramewith a texture, rect, rotated, offset and originalSize in pixels. | |
Static Public Member Functions |
|
staticCCSpriteFrame* | frameWithTexture(CCTexture2D*pobTexture, constCCRect&rect) |
Create aCCSpriteFramewith a texture, rect in points. | |
staticCCSpriteFrame* | frameWithTexture(CCTexture2D*pobTexture, constCCRect&rect, bool rotated, constCCPoint&offset, constCCSize&originalSize) |
Create aCCSpriteFramewith a texture, rect, rotated, offset and originalSize in pixels. | |
Protected Attributes |
|
CCRect | m_obRectInPixels |
bool | m_bRotated |
CCRect | m_obRect |
CCPoint | m_obOffsetInPixels |
CCSize | m_obOriginalSizeInPixels |
CCTexture2D* | m_pobTexture |
ACCSpriteFramehas:
You can modify the frame of aCCSpriteby doing:
CCSpriteFrame*frame = CCSpriteFrame::frameWithTexture(texture, rect, offset); sprite->setDisplayFrame(frame);