cocos2d-x  3.2
 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
var getRectInPixels ()
local getRectInPixels ()
void setRectInPixels (const Rect &rectInPixels)
local setRectInPixels ( local rectInPixels)
bool isRotated (void) const
var isRotated ()
local isRotated ()
void setRotated (bool rotated)
var setRotated ( var rotated)
local setRotated ( local rotated)
const RectgetRect (void) const
 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 (void) const
 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...
 
var setOffsetInPixels ( var offsetInPixels)
 set offset of the frame More...
 
local setOffsetInPixels ( local offsetInPixels)
 set offset of the frame More...
 
const SizegetOriginalSizeInPixels (void) const
 get original size of the trimmed image More...
 
var getOriginalSizeInPixels ()
 get original size of the trimmed image More...
 
local getOriginalSizeInPixels ()
 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 (void) 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 (void)
 get texture of the frame More...
 
var getTexture ()
 get texture of the frame More...
 
local getTexture ()
 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 (void) const
void setOffset (const Vec2 &offsets)
var setOffset ( var offsets)
local setOffset ( local offsets)
virtual SpriteFrameclone () const override
 returns a copy of the Ref More...
 
virtual ~SpriteFrame (void)
var ~SpriteFrame ()
bool initWithTexture (Texture2D *pobTexture, const Rect &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...
 
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. 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 ()
- Public Member Functions inherited from Clonable
virtual ~Clonable ()
Refcopy () const
 returns a copy of the Ref. More...
 
var copy ()
 returns a copy of the Ref. More...
 
local copy ()
 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...
 
var createWithTexture ( var pobTexture, var rect)
 Create a SpriteFrame with a texture, rect in points. More...
 
local createWithTexture ( local pobTexture, local 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(void)

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...
 

Additional Inherited Members

- Protected Member Functions inherited from Ref
 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 ( void  )
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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

const Vec2& getOffset ( void  ) const
var getOffset (   )
local getOffset (   )
const Vec2& getOffsetInPixels ( void  ) const

get offset of the frame

var getOffsetInPixels (   )

get offset of the frame

local getOffsetInPixels (   )

get offset of the frame

const Size& getOriginalSize ( void  ) const
inline

get original size of the trimmed image

var getOriginalSize (   )
inline

get original size of the trimmed image

local getOriginalSize (   )
inline

get original size of the trimmed image

const Size& getOriginalSizeInPixels ( void  ) const
inline

get original size of the trimmed image

var getOriginalSizeInPixels (   )
inline

get original size of the trimmed image

local getOriginalSizeInPixels (   )
inline

get original size of the trimmed image

const Rect& getRect ( void  ) const
inline

get rect of the frame

var getRect (   )
inline

get rect of the frame

local getRect (   )
inline

get rect of the frame

const Rect& getRectInPixels ( ) const
inline
var getRectInPixels ( )
inline
local getRectInPixels ( )
inline
Texture2D* getTexture ( void  )

get texture of the frame

var getTexture (   )

get texture of the frame

local getTexture (   )

get texture of the 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 ( void  ) const
inline
var isRotated (   )
inline
local isRotated (   )
inline
void setOffset ( const Vec2 offsets)
var setOffset ( var  offsets)
local setOffset ( local  offsets)
void setOffsetInPixels ( const Vec2 offsetInPixels)

set offset of the frame

var setOffsetInPixels ( var  offsetInPixels)

set offset of the frame

local setOffsetInPixels ( local  offsetInPixels)

set offset of the frame

void setOriginalSize ( const Size sizeInPixels)
inline

set original size of the trimmed image

var setOriginalSize ( var  sizeInPixels)
inline

set original size of the trimmed image

local setOriginalSize ( local  sizeInPixels)
inline

set original size of the trimmed image

void setOriginalSizeInPixels ( const Size sizeInPixels)
inline

set original size of the trimmed image

var setOriginalSizeInPixels ( var  sizeInPixels)
inline

set original size of the trimmed image

local setOriginalSizeInPixels ( local  sizeInPixels)
inline

set original size of the trimmed image

void setRect ( const Rect rect)

set rect of the frame

var setRect ( var  rect)

set rect of the frame

local setRect ( local  rect)

set rect of the frame

void setRectInPixels ( const Rect rectInPixels)
var setRectInPixels ( var  rectInPixels)
local setRectInPixels ( local  rectInPixels)
void setRotated ( bool  rotated)
inline
var setRotated ( var  rotated)
inline
local setRotated ( local  rotated)
inline
void setTexture ( Texture2D pobTexture)

set texture of the frame, the texture is retained

var setTexture ( var  pobTexture)

set texture of the frame, the texture is retained

local setTexture ( local  pobTexture)

set texture of the frame, the texture is retained

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: