cocos2d-x  2.2
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
CCSpriteFrame Class Reference

A CCSpriteFrame has: More...

#include <CCSpriteFrame.h>

Inheritance diagram for CCSpriteFrame:
CCObject CCCopying

Public Member Functions

const CCRectgetRectInPixels (void)
void setRectInPixels (const CCRect &rectInPixels)
bool isRotated (void)
void setRotated (bool bRotated)
const CCRectgetRect (void)
 get rect of the frame More...
 
void setRect (const CCRect &rect)
 set rect of the frame More...
 
const CCPointgetOffsetInPixels (void)
 get offset of the frame More...
 
void setOffsetInPixels (const CCPoint &offsetInPixels)
 set offset of the frame More...
 
const CCSizegetOriginalSizeInPixels (void)
 get original size of the trimmed image More...
 
void setOriginalSizeInPixels (const CCSize &sizeInPixels)
 set original size of the trimmed image More...
 
const CCSizegetOriginalSize (void)
 get original size of the trimmed image More...
 
void setOriginalSize (const CCSize &sizeInPixels)
 set original size of the trimmed image More...
 
CCTexture2DgetTexture (void)
 get texture of the frame More...
 
void setTexture (CCTexture2D *pobTexture)
 set texture of the frame, the texture is retained More...
 
const CCPointgetOffset (void)
void setOffset (const CCPoint &offsets)
 ~CCSpriteFrame (void)
virtual CCObjectcopyWithZone (CCZone *pZone)
bool initWithTexture (CCTexture2D *pobTexture, const CCRect &rect)
 Initializes a CCSpriteFrame with a texture, rect in points. More...
 
bool initWithTextureFilename (const char *filename, const CCRect &rect)
 Initializes a CCSpriteFrame with a texture filename, rect in points; It is assumed that the frame was not trimmed. More...
 
bool initWithTexture (CCTexture2D *pobTexture, const CCRect &rect, bool rotated, const CCPoint &offset, const CCSize &originalSize)
 Initializes a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 
bool initWithTextureFilename (const char *filename, const CCRect &rect, bool rotated, const CCPoint &offset, const CCSize &originalSize)
 Initializes a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 
- Public Member Functions inherited from CCObject
 CCObject (void)
virtual ~CCObject (void)
void release (void)
void retain (void)
CCObjectautorelease (void)
CCObjectcopy (void)
bool isSingleReference (void) const
unsigned int retainCount (void) const
virtual bool isEqual (const CCObject *pObject)
virtual void acceptVisitor (CCDataVisitor &visitor)
virtual void update (float dt)

Static Public Member Functions

static CCSpriteFramecreate (const char *filename, const CCRect &rect)
 Create a CCSpriteFrame with a texture filename, rect in points. More...
 
static CCSpriteFramecreate (const char *filename, const CCRect &rect, bool rotated, const CCPoint &offset, const CCSize &originalSize)
 Create a CCSpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. More...
 
static CCSpriteFramecreateWithTexture (CCTexture2D *pobTexture, const CCRect &rect)
 Create a CCSpriteFrame with a texture, rect in points. More...
 
static CCSpriteFramecreateWithTexture (CCTexture2D *pobTexture, const CCRect &rect, bool rotated, const CCPoint &offset, const CCSize &originalSize)
 Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 

Protected Attributes

CCPoint m_obOffset
CCSize m_obOriginalSize
CCRect m_obRectInPixels
bool m_bRotated
CCRect m_obRect
CCPoint m_obOffsetInPixels
CCSize m_obOriginalSizeInPixels
CCTexture2Dm_pobTexture
std::string m_strTextureFilename
- Protected Attributes inherited from CCObject
unsigned int m_uReference
unsigned int m_uAutoReleaseCount

Additional Inherited Members

- Public Attributes inherited from CCObject
unsigned int m_uID
int m_nLuaID

Detailed Description

A CCSpriteFrame has:

  • texture: A CCTexture2D that will be used by the CCSprite
  • rectangle: A rectangle of the texture

You can modify the frame of a CCSprite by doing:

CCSpriteFrame *frame = CCSpriteFrame::frameWithTexture(texture, rect, offset); sprite->setDisplayFrame(frame);

Constructor & Destructor Documentation

~CCSpriteFrame ( void  )

Member Function Documentation

virtual CCObject* copyWithZone ( CCZone pZone)
virtual

Reimplemented from CCCopying.

static CCSpriteFrame* create ( const char *  filename,
const CCRect rect 
)
static

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,
bool  rotated,
const CCPoint offset,
const CCSize originalSize 
)
static

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*
createWithTexture
( CCTexture2D pobTexture,
const CCRect rect 
)
static

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,
bool  rotated,
const CCPoint offset,
const CCSize originalSize 
)
static

Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.

The originalSize is the size in points of the frame before being trimmed.

const CCPoint& getOffset ( void  )
const CCPoint& getOffsetInPixels ( void  )

get offset of the frame

const CCSize& getOriginalSize ( void  )
inline

get original size of the trimmed image

const CCSize&
getOriginalSizeInPixels
( void  )
inline

get original size of the trimmed image

const CCRect& getRect ( void  )
inline

get rect of the frame

const CCRect& getRectInPixels ( void  )
inline
CCTexture2D* getTexture ( void  )

get texture of the frame

bool initWithTexture ( CCTexture2D pobTexture,
const CCRect rect 
)

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,
bool  rotated,
const CCPoint offset,
const CCSize originalSize 
)

Initializes a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.

The originalSize is the size in points of the frame before being trimmed.

bool initWithTextureFilename ( const char *  filename,
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,
bool  rotated,
const CCPoint offset,
const CCSize originalSize 
)

Initializes a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.

The originalSize is the size in pixels of the frame before being trimmed.

Since
v1.1
bool isRotated ( void  )
inline
void setOffset ( const CCPoint offsets)
void setOffsetInPixels ( const CCPoint offsetInPixels)

set offset of the frame

void setOriginalSize ( const CCSize sizeInPixels)
inline

set original size of the trimmed image

void setOriginalSizeInPixels ( const CCSize sizeInPixels)
inline

set original size of the trimmed image

void setRect ( const CCRect rect)

set rect of the frame

void setRectInPixels ( const CCRect rectInPixels)
void setRotated ( bool  bRotated)
inline
void setTexture ( CCTexture2D pobTexture)

set texture of the frame, the texture is retained

Member Data Documentation

bool m_bRotated
protected
CCPoint m_obOffset
protected
CCPoint m_obOffsetInPixels
protected
CCSize m_obOriginalSize
protected
CCSize m_obOriginalSizeInPixels
protected
CCRect m_obRect
protected
CCRect m_obRectInPixels
protected
CCTexture2D* m_pobTexture
protected
std::string m_strTextureFilename
protected

The documentation for this class was generated from the following file: