《不靠谱2.x》006.CCSprite(上)003 CCSpriteFrame
发布时间:2020-12-14 21:41:09 所属栏目:百科 来源:网络整理
导读:一、概述 CCSpriteFrame继承自CCObject。看了源码后感觉和CCTexture2D一样,不常直接使用、更多作为中间变量。源码如下: class CC_DLL CCSpriteFrame : public CCObject{ public : // attributes inline const CCRect getRectInPixels ( void ) { return m_
一、概述 class CC_DLL CCSpriteFrame : public CCObject
{
public:
// attributes
inline const CCRect& getRectInPixels(void) { return m_obRectInPixels; }
void setRectInPixels(const CCRect& rectInPixels);
inline bool isRotated(void) { return m_bRotated; }
inline void setRotated(bool bRotated) { m_bRotated = bRotated; }
/** get rect of the frame */
inline const CCRect& getRect(void) { return m_obRect; }
/** set rect of the frame */
void setRect(const CCRect& rect);
/** get offset of the frame */
const CCPoint& getOffsetInPixels(void);
/** set offset of the frame */
void setOffsetInPixels(const CCPoint& offsetInPixels);
/** get original size of the trimmed image */
inline const CCSize& getOriginalSizeInPixels(void) { return m_obOriginalSizeInPixels; }
/** set original size of the trimmed image */
inline void setOriginalSizeInPixels(const CCSize& sizeInPixels) { m_obOriginalSizeInPixels = sizeInPixels; }
/** get original size of the trimmed image */
inline const CCSize& getOriginalSize(void) { return m_obOriginalSize; }
/** set original size of the trimmed image */
inline void setOriginalSize(const CCSize& sizeInPixels) { m_obOriginalSize = sizeInPixels; }
/** get texture of the frame */
CCTexture2D* getTexture(void);
/** set texture of the frame,the texture is retained */
void setTexture(CCTexture2D* pobTexture);
const CCPoint& getOffset(void);
void setOffset(const CCPoint& offsets);
public:
/**
* @js NA
* @lua NA
*/
~CCSpriteFrame(void);
/** * @js NA * @lua NA */
virtual CCObject* copyWithZone(CCZone *pZone);
/** Create a CCSpriteFrame with a texture filename,rect in points. It is assumed that the frame was not trimmed. */
static CCSpriteFrame* create(const char* filename,const CCRect& rect);
/** Create a CCSpriteFrame with a texture filename,rect,rotated,offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. */
static CCSpriteFrame* create(const char* filename,const CCRect& rect,bool rotated,const CCPoint& offset,const CCSize& originalSize);
/** Create a CCSpriteFrame with a texture,rect in points. It is assumed that the frame was not trimmed. */
static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture,const CCRect& rect);
/** Create a CCSpriteFrame with a texture,offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. */
static CCSpriteFrame* createWithTexture(CCTexture2D* pobTexture,const CCSize& originalSize);
public:
/** Initializes a CCSpriteFrame with a texture,rect in points.
It is assumed that the frame was not trimmed.
*/
bool initWithTexture(CCTexture2D* pobTexture,const CCRect& rect);
/** Initializes a CCSpriteFrame with a texture filename,rect in points; It is assumed that the frame was not trimmed. */
bool initWithTextureFilename(const char* filename,const CCRect& rect);
/** Initializes a CCSpriteFrame with a texture,offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. */
bool initWithTexture(CCTexture2D* pobTexture,const CCSize& originalSize);
/** Initializes a CCSpriteFrame with a texture,offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. @since v1.1 */
bool initWithTextureFilename(const char* filename,const CCSize& originalSize);
protected:
CCPoint m_obOffset;
CCSize m_obOriginalSize;
CCRect m_obRectInPixels;
bool m_bRotated;
CCRect m_obRect;
CCPoint m_obOffsetInPixels;
CCSize m_obOriginalSizeInPixels;
CCTexture2D *m_pobTexture;
std::string m_strTextureFilename;
};
二、分析 三、总结 1、可通过文件名、纹理、纹理文件名生成CCSpriteFrame对象 2、不常直接使用,更多的作为中间变量 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- c# – 私有EventHandler和私有事件EventHandler之
- 如何处理/使用Oracle SQL查询中的百分比(%)和符
- logback logback.xml常用配置详解(三) <filter
- 如何判断sqlite列是否为AUTOINCREMENT?
- 正则表达式 符号 解释
- postgresql – CakePHP paginator区分大小写
- c# – 使用继承的自定义IDataReader从IDbCommand
- 包的设计原则总结(四) - 稳定依赖原则(SDP)
- ruby-on-rails – PostgreSQL – group by子句或
- 导入项目启动报错Unexpectedexception parsing X
热点阅读