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

A SpriteFrame has: More...

#include <CCSpriteFrame.h>

Inheritance diagram for SpriteFrame:
Ref Clonable

Public Member Functions

const RectgetRectInPixels () const
 Get rect of the sprite frame. More...
 
var getRectInPixels ()
 Get rect of the sprite frame. More...
 
local getRectInPixels ()
 Get rect of the sprite frame. More...
 
void setRectInPixels (const Rect &rectInPixels)
 Set rect of the sprite frame. More...
 
var setRectInPixels ( var rectInPixels)
 Set rect of the sprite frame. More...
 
local setRectInPixels ( local rectInPixels)
 Set rect of the sprite frame. More...
 
bool isRotated () const
 Is the sprite frame rotated or not. More...
 
var isRotated ()
 Is the sprite frame rotated or not. More...
 
local isRotated ()
 Is the sprite frame rotated or not. More...
 
void setRotated (bool rotated)
 Set rotated of the sprite frame. More...
 
var setRotated ( var rotated)
 Set rotated of the sprite frame. More...
 
local setRotated ( local rotated)
 Set rotated of the sprite frame. More...
 
const RectgetRect () const
 Get rect of the frame. More...
 
var getRect ()
 Get rect of the frame. More...
 
local getRect ()
 Get rect of the frame. More...
 
void setRect (const Rect &rect)
 Set rect of the frame. More...
 
var setRect ( var rect)
 Set rect of the frame. More...
 
local setRect ( local rect)
 Set rect of the frame. More...
 
const Vec2getOffsetInPixels () const
 Get offset of the frame. More...
 
var getOffsetInPixels ()
 Get offset of the frame. More...
 
local getOffsetInPixels ()
 Get offset of the frame. More...
 
void setOffsetInPixels (const Vec2 &offsetInPixels)
 Set offset of the frame. More...
 
const SizegetOriginalSizeInPixels () const
 Get original size of the trimmed image. More...
 
void setOriginalSizeInPixels (const Size &sizeInPixels)
 Set original size of the trimmed image. More...
 
var setOriginalSizeInPixels ( var sizeInPixels)
 Set original size of the trimmed image. More...
 
local setOriginalSizeInPixels ( local sizeInPixels)
 Set original size of the trimmed image. More...
 
const SizegetOriginalSize () const
 Get original size of the trimmed image. More...
 
var getOriginalSize ()
 Get original size of the trimmed image. More...
 
local getOriginalSize ()
 Get original size of the trimmed image. More...
 
void setOriginalSize (const Size &sizeInPixels)
 Set original size of the trimmed image. More...
 
var setOriginalSize ( var sizeInPixels)
 Set original size of the trimmed image. More...
 
local setOriginalSize ( local sizeInPixels)
 Set original size of the trimmed image. More...
 
Texture2DgetTexture ()
 Get texture of the frame. More...
 
void setTexture (Texture2D *pobTexture)
 Set texture of the frame, the texture is retained. More...
 
var setTexture ( var pobTexture)
 Set texture of the frame, the texture is retained. More...
 
local setTexture ( local pobTexture)
 Set texture of the frame, the texture is retained. More...
 
const Vec2getOffset () const
 Get offset of the frame. More...
 
void setOffset (const Vec2 &offsets)
 Set offset of the frame. More...
 
var setOffset ( var offsets)
 Set offset of the frame. More...
 
local setOffset ( local offsets)
 Set offset of the frame. More...
 
virtual SpriteFrameclone () const override
 Returns a copy of the Ref. More...
 
var clone ()
 Returns a copy of the Ref. More...
 
local clone ()
 Returns a copy of the Ref. More...
 
virtual ~SpriteFrame ()
var ~SpriteFrame ()
bool initWithTexture (Texture2D *pobTexture, const Rect &rect)
 Initializes a SpriteFrame with a texture, rect in points. More...
 
var initWithTexture ( var pobTexture, var rect)
 Initializes a SpriteFrame with a texture, rect in points. More...
 
local initWithTexture ( local pobTexture, local rect)
 Initializes a SpriteFrame with a texture, rect in points. More...
 
bool initWithTextureFilename (const std::string &filename, const Rect &rect)
 Initializes a SpriteFrame with a texture filename, rect in points; It is assumed that the frame was not trimmed. More...
 
local initWithTextureFilename ( local filename, local rect)
 Initializes a SpriteFrame with a texture filename, rect in points; It is assumed that the frame was not trimmed. More...
 
bool initWithTexture (Texture2D *pobTexture, const Rect &rect, bool rotated, const Vec2 &offset, const Size &originalSize)
 Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 
var initWithTexture ( var pobTexture, var rect, var rotated, var offset, var originalSize)
 Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 
local initWithTexture ( local pobTexture, local rect, local rotated, local offset, local originalSize)
 Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 
bool initWithTextureFilename (const std::string &filename, const Rect &rect, bool rotated, const Vec2 &offset, const Size &originalSize)
 Initializes a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 
- Public Member Functions inherited from Ref
void retain ()
 Retains the ownership. More...
 
void release ()
 Releases the ownership immediately. More...
 
Refautorelease ()
 Releases the ownership sometime soon automatically. More...
 
unsigned int getReferenceCount () const
 Returns the Ref's current reference count. More...
 
virtual ~Ref ()
 Destructor. More...
 
- Public Member Functions inherited from Clonable
virtual ~Clonable ()
Refcopy () const
 Returns a copy of the Ref. More...
 

Static Public Member Functions

static SpriteFramecreate (const std::string &filename, const Rect &rect)
 Create a SpriteFrame with a texture filename, rect in points. More...
 
var create ( var filename, var rect)
 Create a SpriteFrame with a texture filename, rect in points. More...
 
local create ( local filename, local rect)
 Create a SpriteFrame with a texture filename, rect in points. More...
 
static SpriteFramecreate (const std::string &filename, const Rect &rect, bool rotated, const Vec2 &offset, const Size &originalSize)
 Create a SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. More...
 
static SpriteFramecreateWithTexture (Texture2D *pobTexture, const Rect &rect)
 Create a SpriteFrame with a texture, rect in points. More...
 
static SpriteFramecreateWithTexture (Texture2D *pobTexture, const Rect &rect, bool rotated, const Vec2 &offset, const Size &originalSize)
 Create a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 
var createWithTexture ( var pobTexture, var rect, var rotated, var offset, var originalSize)
 Create a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 
local createWithTexture ( local pobTexture, local rect, local rotated, local offset, local originalSize)
 Create a SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. More...
 

Public Attributes

CC_CONSTRUCTOR_ACCESS __pad0__: SpriteFrame()

Protected Attributes

Vec2 _offset
Size _originalSize
var _originalSize
local _originalSize
Rect _rectInPixels
var _rectInPixels
local _rectInPixels
bool _rotated
var _rotated
local _rotated
Rect _rect
var _rect
local _rect
Vec2 _offsetInPixels
var _offsetInPixels
local _offsetInPixels
Size _originalSizeInPixels
var _originalSizeInPixels
local _originalSizeInPixels
Texture2D_texture
var _texture
local _texture
std::string _textureFilename
var _textureFilename
local _textureFilename
- Protected Attributes inherited from Ref
unsigned int _referenceCount
 count of references More...
 
local _referenceCount
 count of references More...
 

Additional Inherited Members

- Protected Member Functions inherited from Ref
 Ref ()
 Constructor. More...
 
 Ref ()
 Constructor. More...
 

Detailed Description

A SpriteFrame has:

  • texture: A Texture2D that will be used by the Sprite
  • rectangle: A rectangle of the texture

You can modify the frame of a Sprite by doing:

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

Constructor & Destructor Documentation

virtual ~SpriteFrame ( )
virtual
var ~SpriteFrame ( )
virtual

Member Function Documentation

virtual SpriteFrame* clone ( ) const
overridevirtual

Returns a copy of the Ref.

Implements Clonable.

var clone ( )
overridevirtual

Returns a copy of the Ref.

Implements Clonable.

local clone ( )
overridevirtual

Returns a copy of the Ref.

Implements Clonable.

static SpriteFrame* create ( const std::string &  filename,
const Rect rect 
)
static

Create a SpriteFrame with a texture filename, rect in points.

It is assumed that the frame was not trimmed.

Parameters
filenameTexture file name.
rectA specified rect.
Returns
An autoreleased SpriteFrame object.
var create ( var  filename,
var  rect 
)
static

Create a SpriteFrame with a texture filename, rect in points.

It is assumed that the frame was not trimmed.

Parameters
filenameTexture file name.
rectA specified rect.
Returns
An autoreleased SpriteFrame object.
local create ( local  filename,
local  rect 
)
static

Create a SpriteFrame with a texture filename, rect in points.

It is assumed that the frame was not trimmed.

Parameters
filenameTexture file name.
rectA specified rect.
Returns
An autoreleased SpriteFrame object.
static SpriteFrame* create ( const std::string &  filename,
const Rect rect,
bool  rotated,
const Vec2 offset,
const Size originalSize 
)
static

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

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

Parameters
filenameTexture filename
rectA specified rect.
rotatedIs rotated if true.
offsetA specified offset.
originalSizeA specified original size.
Returns
An autoreleased SpriteFrame object.
var create ( var  filename,
var  rect,
var  rotated,
var  offset,
var  originalSize 
)
static

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

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

Parameters
filenameTexture filename
rectA specified rect.
rotatedIs rotated if true.
offsetA specified offset.
originalSizeA specified original size.
Returns
An autoreleased SpriteFrame object.
local create ( local  filename,
local  rect,
local  rotated,
local  offset,
local  originalSize 
)
static

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

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

Parameters
filenameTexture filename
rectA specified rect.
rotatedIs rotated if true.
offsetA specified offset.
originalSizeA specified original size.
Returns
An autoreleased SpriteFrame object.
static SpriteFrame*
createWithTexture
( Texture2D pobTexture,
const Rect rect 
)
static

Create a SpriteFrame with a texture, rect in points.

It is assumed that the frame was not trimmed.

Parameters
pobTextureThe texture pointer.
rectA specified rect.
Returns
An autoreleased SpriteFrame object.
var createWithTexture ( var  pobTexture,
var  rect 
)
static

Create a SpriteFrame with a texture, rect in points.

It is assumed that the frame was not trimmed.

Parameters
pobTextureThe texture pointer.
rectA specified rect.
Returns
An autoreleased SpriteFrame object.
local createWithTexture ( local  pobTexture,
local  rect 
)
static

Create a SpriteFrame with a texture, rect in points.

It is assumed that the frame was not trimmed.

Parameters
pobTextureThe texture pointer.
rectA specified rect.
Returns
An autoreleased SpriteFrame object.
static SpriteFrame*
createWithTexture
( Texture2D pobTexture,
const Rect rect,
bool  rotated,
const Vec2 offset,
const Size originalSize 
)
static

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

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

Parameters
pobTextureThe texture pointer.
rectA specified rect.
rotatedIs rotated if true.
offsetA specified offset.
originalSizeA specified original size.
Returns
An autoreleased SpriteFrame object.
var createWithTexture ( var  pobTexture,
var  rect,
var  rotated,
var  offset,
var  originalSize 
)
static

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

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

Parameters
pobTextureThe texture pointer.
rectA specified rect.
rotatedIs rotated if true.
offsetA specified offset.
originalSizeA specified original size.
Returns
An autoreleased SpriteFrame object.
local createWithTexture ( local  pobTexture,
local  rect,
local  rotated,
local  offset,
local  originalSize 
)
static

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

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

Parameters
pobTextureThe texture pointer.
rectA specified rect.
rotatedIs rotated if true.
offsetA specified offset.
originalSizeA specified original size.
Returns
An autoreleased SpriteFrame object.
const Vec2& getOffset ( ) const

Get offset of the frame.

Returns
The offset of the sprite frame.
var getOffset ( )

Get offset of the frame.

Returns
The offset of the sprite frame.
local getOffset ( )

Get offset of the frame.

Returns
The offset of the sprite frame.
const Vec2& getOffsetInPixels ( ) const

Get offset of the frame.

Returns
The offset of the sprite frame, in pixels.
var getOffsetInPixels ( )

Get offset of the frame.

Returns
The offset of the sprite frame, in pixels.
local getOffsetInPixels ( )

Get offset of the frame.

Returns
The offset of the sprite frame, in pixels.
const Size& getOriginalSize ( ) const
inline

Get original size of the trimmed image.

Returns
The original size of the trimmed image.
var getOriginalSize ( )
inline

Get original size of the trimmed image.

Returns
The original size of the trimmed image.
local getOriginalSize ( )
inline

Get original size of the trimmed image.

Returns
The original size of the trimmed image.
const Size& getOriginalSizeInPixels ( ) const
inline

Get original size of the trimmed image.

Returns
The original size of the trimmed image, in pixels.
var getOriginalSizeInPixels ( )
inline

Get original size of the trimmed image.

Returns
The original size of the trimmed image, in pixels.
local getOriginalSizeInPixels ( )
inline

Get original size of the trimmed image.

Returns
The original size of the trimmed image, in pixels.
const Rect& getRect ( ) const
inline

Get rect of the frame.

Returns
The rect of the sprite frame.
var getRect ( )
inline

Get rect of the frame.

Returns
The rect of the sprite frame.
local getRect ( )
inline

Get rect of the frame.

Returns
The rect of the sprite frame.
const Rect& getRectInPixels ( ) const
inline

Get rect of the sprite frame.

Returns
The rect of the sprite frame, in pixels.
var getRectInPixels ( )
inline

Get rect of the sprite frame.

Returns
The rect of the sprite frame, in pixels.
local getRectInPixels ( )
inline

Get rect of the sprite frame.

Returns
The rect of the sprite frame, in pixels.
Texture2D* getTexture ( )

Get texture of the frame.

Returns
The texture of the sprite frame.
var getTexture ( )

Get texture of the frame.

Returns
The texture of the sprite frame.
local getTexture ( )

Get texture of the frame.

Returns
The texture of the sprite frame.
bool initWithTexture ( Texture2D pobTexture,
const Rect rect 
)

Initializes a SpriteFrame with a texture, rect in points.

It is assumed that the frame was not trimmed.

var initWithTexture ( var  pobTexture,
var  rect 
)

Initializes a SpriteFrame with a texture, rect in points.

It is assumed that the frame was not trimmed.

local initWithTexture ( local  pobTexture,
local  rect 
)

Initializes a SpriteFrame with a texture, rect in points.

It is assumed that the frame was not trimmed.

bool initWithTexture ( Texture2D pobTexture,
const Rect rect,
bool  rotated,
const Vec2 offset,
const Size originalSize 
)

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

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

var initWithTexture ( var  pobTexture,
var  rect,
var  rotated,
var  offset,
var  originalSize 
)

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

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

local initWithTexture ( local  pobTexture,
local  rect,
local  rotated,
local  offset,
local  originalSize 
)

Initializes a SpriteFrame 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 std::string &  filename,
const Rect rect 
)

Initializes a SpriteFrame with a texture filename, rect in points; It is assumed that the frame was not trimmed.

var initWithTextureFilename ( var  filename,
var  rect 
)

Initializes a SpriteFrame with a texture filename, rect in points; It is assumed that the frame was not trimmed.

local initWithTextureFilename ( local  filename,
local  rect 
)

Initializes a SpriteFrame with a texture filename, rect in points; It is assumed that the frame was not trimmed.

bool initWithTextureFilename ( const std::string &  filename,
const Rect rect,
bool  rotated,
const Vec2 offset,
const Size originalSize 
)

Initializes a SpriteFrame 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
var initWithTextureFilename ( var  filename,
var  rect,
var  rotated,
var  offset,
var  originalSize 
)

Initializes a SpriteFrame 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
local initWithTextureFilename ( local  filename,
local  rect,
local  rotated,
local  offset,
local  originalSize 
)

Initializes a SpriteFrame 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 ( ) const
inline

Is the sprite frame rotated or not.

Returns
Is rotated if true.
var isRotated ( )
inline

Is the sprite frame rotated or not.

Returns
Is rotated if true.
local isRotated ( )
inline

Is the sprite frame rotated or not.

Returns
Is rotated if true.
void setOffset ( const Vec2 offsets)

Set offset of the frame.

Parameters
offsetsThe offset of the sprite frame.
var setOffset ( var  offsets)

Set offset of the frame.

Parameters
offsetsThe offset of the sprite frame.
local setOffset ( local  offsets)

Set offset of the frame.

Parameters
offsetsThe offset of the sprite frame.
void setOffsetInPixels ( const Vec2 offsetInPixels)

Set offset of the frame.

Parameters
offsetInPixelsThe offset of the sprite frame, in pixels.
var setOffsetInPixels ( var  offsetInPixels)

Set offset of the frame.

Parameters
offsetInPixelsThe offset of the sprite frame, in pixels.
local setOffsetInPixels ( local  offsetInPixels)

Set offset of the frame.

Parameters
offsetInPixelsThe offset of the sprite frame, in pixels.
void setOriginalSize ( const Size sizeInPixels)
inline

Set original size of the trimmed image.

Parameters
sizeInPixelsThe original size of the trimmed image.
var setOriginalSize ( var  sizeInPixels)
inline

Set original size of the trimmed image.

Parameters
sizeInPixelsThe original size of the trimmed image.
local setOriginalSize ( local  sizeInPixels)
inline

Set original size of the trimmed image.

Parameters
sizeInPixelsThe original size of the trimmed image.
void setOriginalSizeInPixels ( const Size sizeInPixels)
inline

Set original size of the trimmed image.

Parameters
sizeInPixelsThe original size of the trimmed image, in pixels.
var setOriginalSizeInPixels ( var  sizeInPixels)
inline

Set original size of the trimmed image.

Parameters
sizeInPixelsThe original size of the trimmed image, in pixels.
local setOriginalSizeInPixels ( local  sizeInPixels)
inline

Set original size of the trimmed image.

Parameters
sizeInPixelsThe original size of the trimmed image, in pixels.
void setRect ( const Rect rect)

Set rect of the frame.

Parameters
Therect of the sprite.
var setRect ( var  rect)

Set rect of the frame.

Parameters
Therect of the sprite.
local setRect ( local  rect)

Set rect of the frame.

Parameters
Therect of the sprite.
void setRectInPixels ( const Rect rectInPixels)

Set rect of the sprite frame.

Parameters
rectInPixelsThe rect of the sprite frame, in pixels.
var setRectInPixels ( var  rectInPixels)

Set rect of the sprite frame.

Parameters
rectInPixelsThe rect of the sprite frame, in pixels.
local setRectInPixels ( local  rectInPixels)

Set rect of the sprite frame.

Parameters
rectInPixelsThe rect of the sprite frame, in pixels.
void setRotated ( bool  rotated)
inline

Set rotated of the sprite frame.

Parameters
rotatedRotated the sprite frame if true.
var setRotated ( var  rotated)
inline

Set rotated of the sprite frame.

Parameters
rotatedRotated the sprite frame if true.
local setRotated ( local  rotated)
inline

Set rotated of the sprite frame.

Parameters
rotatedRotated the sprite frame if true.
void setTexture ( Texture2D pobTexture)

Set texture of the frame, the texture is retained.

Parameters
pobTextureThe texture of the sprite frame.
var setTexture ( var  pobTexture)

Set texture of the frame, the texture is retained.

Parameters
pobTextureThe texture of the sprite frame.
local setTexture ( local  pobTexture)

Set texture of the frame, the texture is retained.

Parameters
pobTextureThe texture of the sprite frame.

Member Data Documentation

Vec2 _offset
protected
Vec2 _offsetInPixels
protected
var _offsetInPixels
protected
local _offsetInPixels
protected
Size _originalSize
protected
var _originalSize
protected
local _originalSize
protected
Size _originalSizeInPixels
protected
var _originalSizeInPixels
protected
local _originalSizeInPixels
protected
Rect _rect
protected
var _rect
protected
local _rect
protected
Rect _rectInPixels
protected
var _rectInPixels
protected
local _rectInPixels
protected
bool _rotated
protected
var _rotated
protected
local _rotated
protected
Texture2D* _texture
protected
var _texture
protected
local _texture
protected
std::string _textureFilename
protected
var _textureFilename
protected
local _textureFilename
protected

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