A SpriteFrame has:
More...
Inherits Ref, and Clonable.
|
static SpriteFrame * | create (const std::string &filename, const Rect &rect) |
| Create a SpriteFrame with a texture filename, rect in points.
|
|
static SpriteFrame * | create (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.
|
|
static SpriteFrame * | createWithTexture (Texture2D *pobTexture, const Rect &rect) |
| Create a SpriteFrame with a texture, rect in points.
|
|
static SpriteFrame * | createWithTexture (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.
|
|
|
| SpriteFrame () |
| NA
|
|
virtual | ~SpriteFrame () |
| NA
|
|
bool | initWithTexture (Texture2D *pobTexture, const Rect &rect) |
| Initializes a SpriteFrame with a texture, rect in points.
|
|
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.
|
|
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.
|
|
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.
|
|
|
unsigned int | _ID |
| object id, ScriptSupport need public _ID
|
|
int | _luaID |
| Lua reference id.
|
|
void * | _scriptObject |
| scriptObject, support for swift
|
|
bool | _rooted |
| When true, it means that the object was already rooted.
|
|
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:
sprite->setSpriteFrame(frame);
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
-
filename | Texture file name. |
rect | A 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
-
filename | Texture filename |
rect | A specified rect. |
rotated | Is rotated if true. |
offset | A specified offset. |
originalSize | A specified original size. |
- Returns
- An autoreleased SpriteFrame object.
Create a SpriteFrame with a texture, rect in points.
It is assumed that the frame was not trimmed.
- Parameters
-
pobTexture | The texture pointer. |
rect | A 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
-
pobTexture | The texture pointer. |
rect | A specified rect. |
rotated | Is rotated if true. |
offset | A specified offset. |
originalSize | A specified original size. |
- Returns
- An autoreleased SpriteFrame object.
const Rect& getRectInPixels |
( |
| ) |
const |
|
inline |
Get rect of the sprite frame.
- Returns
- The rect of the sprite frame, in pixels.
void setRectInPixels |
( |
const Rect & |
rectInPixels | ) |
|
Set rect of the sprite frame.
- Parameters
-
rectInPixels | The rect of the sprite frame, in pixels. |
Is the sprite frame rotated or not.
- Returns
- Is rotated if true.
void setRotated |
( |
bool |
rotated | ) |
|
|
inline |
Set rotated of the sprite frame.
- Parameters
-
rotated | Rotated the sprite frame if true. |
const Rect& getRect |
( |
| ) |
const |
|
inline |
Get rect of the frame.
- Returns
- The rect of the sprite frame.
void setRect |
( |
const Rect & |
rect | ) |
|
Set rect of the frame.
- Parameters
-
rect | The rect of the sprite. |
const Rect& getCenterRect |
( |
| ) |
const |
|
inline |
Get center rect of the frame.
Useful to create 9-slice sprites
- Returns
- The center rect of the sprite frame in points
void setCenterRectInPixels |
( |
const Rect & |
centerRect | ) |
|
setCenterRect
Useful to implement "9 sliced" sprites. The sprite will be sliced into a 3 x 3 grid. The four corners of this grid are applied without performing any scaling. The upper- and lower-middle parts are scaled horizontally, and the left- and right-middle parts are scaled vertically. The center is scaled in both directions. Important: The scaling is based the Sprite's trimmed size.
Limitations: Does not work when the sprite is part of SpriteBatchNode
.
- Parameters
-
centerRect | the Rect in points |
bool hasCenterRect |
( |
| ) |
const |
hasCenterRect
- Returns
- Whether or not it has a centerRect
const Vec2& getOffsetInPixels |
( |
| ) |
const |
Get offset of the frame.
- Returns
- The offset of the sprite frame, in pixels.
void setOffsetInPixels |
( |
const Vec2 & |
offsetInPixels | ) |
|
Set offset of the frame.
- Parameters
-
offsetInPixels | The offset of the sprite frame, in pixels. |
const Size& getOriginalSizeInPixels |
( |
| ) |
const |
|
inline |
Get original size of the trimmed image.
- Returns
- The original size of the trimmed image, in pixels.
void setOriginalSizeInPixels |
( |
const Size & |
sizeInPixels | ) |
|
|
inline |
Set original size of the trimmed image.
- Parameters
-
sizeInPixels | The original size of the trimmed image, in pixels. |
const Size& getOriginalSize |
( |
| ) |
const |
|
inline |
Get original size of the trimmed image.
- Returns
- The original size of the trimmed image.
void setOriginalSize |
( |
const Size & |
sizeInPixels | ) |
|
|
inline |
Set original size of the trimmed image.
- Parameters
-
sizeInPixels | The original size of the trimmed image. |
Get texture of the frame.
- Returns
- The texture of the sprite frame.
Set texture of the frame, the texture is retained.
- Parameters
-
pobTexture | The texture of the sprite frame. |
const Vec2& getOffset |
( |
| ) |
const |
Get offset of the frame.
- Returns
- The offset of the sprite frame.
void setOffset |
( |
const Vec2 & |
offsets | ) |
|
Set offset of the frame.
- Parameters
-
offsets | The offset of the sprite frame. |
const Vec2& getAnchorPoint |
( |
| ) |
const |
Get anchor point of the frame.
- Returns
- The anchor point of the sprite frame.
void setAnchorPoint |
( |
const Vec2 & |
anchorPoint | ) |
|
Set anchor point of the frame.
- Parameters
-
anchorPoint | The anchor point of the sprite frame. |
bool hasAnchorPoint |
( |
| ) |
const |
Check if anchor point is defined for the frame.
- Returns
- true if anchor point is available.
Set the polygon info for polygon mesh sprites.
- Parameters
-
polygonInfo | triangle mesh of the sprite |
Get the polygonInfo for this sprite.
- Returns
- a reference to the polygonInfo structure
bool hasPolygonInfo |
( |
| ) |
const |
Check if sprite frame is a polygon sprite.
- Returns
- true if polygonInfo is available
bool initWithTexture |
( |
Texture2D * |
pobTexture, |
|
|
const Rect & |
rect |
|
) |
| |
|
protected |
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 |
|
) |
| |
|
protected |
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, |
|
|
bool |
rotated, |
|
|
const Vec2 & |
offset, |
|
|
const Size & |
originalSize |
|
) |
| |
|
protected |
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
The documentation for this class was generated from the following file: