cocos2d-x  2.2.3-gd2.113-rev1ec524e
Loading...
Searching...
No Matches
CCSpriteFrame Class Reference

A CCSpriteFrame has: More...

#include <CCSpriteFrame.h>

Inheritance diagram for CCSpriteFrame:
[legend]
Collaboration diagram for CCSpriteFrame:
[legend]

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)
 NA NA. More...
 
virtual CCObjectcopyWithZone (CCZone *pZone)
 NA NA. More...
 
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)
 NA. More...
 
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)
 
 CCObject (const CCObject &)
 
CCObjectoperator= (const CCObject &)
 
virtual void encodeWithCoder (DS_Dictionary *)
 
virtual bool canEncode ()
 
CCObjectType getObjType () const
 
virtual int getTag () const
 
virtual void setTag (int nTag)
 
void setObjType (CCObjectType)
 
virtual CCObjectcopyWithZone (CCZone *pZone)
 

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...
 
- Static Public Member Functions inherited from CCObject
static CCObjectcreateWithCoder (DS_Dictionary *)
 

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
 
int m_nTag
 
int m_eObjType
 
unsigned int m_uObjectIdxInArray
 

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()

~CCSpriteFrame ( void  )

NA NA.

Member Function Documentation

◆ copyWithZone()

virtual CCObject * copyWithZone ( CCZone pZone)
virtual

NA NA.

Reimplemented from CCCopying.

◆ create() [1/2]

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.

◆ create() [2/2]

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.

◆ createWithTexture() [1/2]

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.

◆ createWithTexture() [2/2]

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.

◆ getOffset()

const CCPoint & getOffset ( void  )

◆ getOffsetInPixels()

const CCPoint & getOffsetInPixels ( void  )

get offset of the frame

◆ getOriginalSize()

const CCSize & getOriginalSize ( void  )
inline

get original size of the trimmed image

◆ getOriginalSizeInPixels()

const CCSize & getOriginalSizeInPixels ( void  )
inline

get original size of the trimmed image

◆ getRect()

const CCRect & getRect ( void  )
inline

get rect of the frame

◆ getRectInPixels()

const CCRect & getRectInPixels ( void  )
inline

◆ getTexture()

CCTexture2D * getTexture ( void  )

get texture of the frame

◆ initWithTexture() [1/2]

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.

◆ initWithTexture() [2/2]

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.

◆ initWithTextureFilename() [1/2]

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.

◆ initWithTextureFilename() [2/2]

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

◆ isRotated()

bool isRotated ( void  )
inline

◆ setOffset()

void setOffset ( const CCPoint offsets)

◆ setOffsetInPixels()

void setOffsetInPixels ( const CCPoint offsetInPixels)

set offset of the frame

◆ setOriginalSize()

void setOriginalSize ( const CCSize sizeInPixels)
inline

set original size of the trimmed image

◆ setOriginalSizeInPixels()

void setOriginalSizeInPixels ( const CCSize sizeInPixels)
inline

set original size of the trimmed image

◆ setRect()

void setRect ( const CCRect rect)

set rect of the frame

◆ setRectInPixels()

void setRectInPixels ( const CCRect rectInPixels)

◆ setRotated()

void setRotated ( bool  bRotated)
inline

◆ setTexture()

void setTexture ( CCTexture2D pobTexture)

set texture of the frame, the texture is retained

Member Data Documentation

◆ m_bRotated

bool m_bRotated
protected

◆ m_obOffset

CCPoint m_obOffset
protected

◆ m_obOffsetInPixels

CCPoint m_obOffsetInPixels
protected

◆ m_obOriginalSize

CCSize m_obOriginalSize
protected

◆ m_obOriginalSizeInPixels

CCSize m_obOriginalSizeInPixels
protected

◆ m_obRect

CCRect m_obRect
protected

◆ m_obRectInPixels

CCRect m_obRectInPixels
protected

◆ m_pobTexture

CCTexture2D* m_pobTexture
protected

◆ m_strTextureFilename

std::string m_strTextureFilename
protected

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