Class Index | File Index

Classes


Class cc.SpriteFrame


Extends cc.Class.

Defined in: CCSpriteFrame.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

A cc.SpriteFrame has:
- texture: A cc.Texture2D that will be used by the cc.Sprite
- rectangle: A rectangle of the texture

You can modify the frame of a cc.Sprite by doing:

Method Summary
Method Attributes Method Name and Description
 
copy a new SpriteFrame
<static>  
cc.SpriteFrame.create(filename, rect, rotated, offset, originalSize)

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

<static>  
cc.SpriteFrame.createWithTexture(texture, rect, rotated, offset, originalSize)
Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
 
ctor()
 
Offset getter
 
get offset of the frame
 
get original size of the trimmed image
 
get original size of the trimmed image
 
get rect of the frame
 
 
get texture of the frame
 
initWithTexture(texture, rect, rotated, offset, originalSize)
Initializes SpriteFrame with Texture, rect, rotated, offset and originalSize in pixels.
 
initWithTextureFilename(filename, rect, rotated, offset, originalSize)

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

 

return is rotated of SpriteFrame.

 
setOffset(offsets)
offset setter
 
setOffsetInPixels(offsetInPixels)
set offset of the frame
 
setOriginalSize(sizeInPixels)
set original size of the trimmed image
 
set original size of the trimmed image
 
setRect(rect)
set rect of the frame
 
setRectInPixels(rectInPixels)
 
setRotated(bRotated)
set SpriteFrame is rotated
 
setTexture(texture)
set texture of the frame, the texture is retained
Class Detail
cc.SpriteFrame()

A cc.SpriteFrame has:
- texture: A cc.Texture2D that will be used by the cc.Sprite
- rectangle: A rectangle of the texture

You can modify the frame of a cc.Sprite by doing:

var texture = cc.TextureCache.getInstance().addImage(s_dragon_animation);
var frame0 = cc.SpriteFrame.createWithTexture(texture, cc.rect(132 * 0, 132 * 0, 132, 132));
Method Detail
{cc.SpriteFrame} copyWithZone()
copy a new SpriteFrame
Returns:
{cc.SpriteFrame}

<static> {cc.SpriteFrame} cc.SpriteFrame.create(filename, rect, rotated, offset, originalSize)

Create a cc.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:
{string} filename
{cc.Rect} rect
{Boolean} rotated
{cc.Point} offset
{cc.Size} originalSize
Returns:
{cc.SpriteFrame}

<static> {cc.SpriteFrame} cc.SpriteFrame.createWithTexture(texture, rect, rotated, offset, originalSize)
Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
//Create a cc.SpriteFrame with a texture, rect in texture.
var frame1 = cc.SpriteFrame.createWithTexture("grossini_dance.png",cc.rect(0,0,90,128));

//Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
var frame2 = cc.SpriteFrame.createWithTexture(texture, frameRect, rotated, offset, sourceSize);
Parameters:
{cc.Texture2D|HTMLImageElement} texture
{cc.Rect} rect
{Boolean} rotated
{cc.Point} offset
{cc.Size} originalSize
Returns:
{cc.SpriteFrame}

ctor()

{cc.Point} getOffset()
Offset getter
Returns:
{cc.Point}

{cc.Point} getOffsetInPixels()
get offset of the frame
Returns:
{cc.Point}

{cc.Size} getOriginalSize()
get original size of the trimmed image
Returns:
{cc.Size}

{cc.Size} getOriginalSizeInPixels()
get original size of the trimmed image
Returns:
{cc.Size}

{cc.Rect} getRect()
get rect of the frame
Returns:
{cc.Rect}

{cc.Rect} getRectInPixels()
Returns:
{cc.Rect}

{cc.Texture2D|HTMLImageElement} getTexture()
get texture of the frame
Returns:
{cc.Texture2D|HTMLImageElement}

{Boolean} initWithTexture(texture, rect, rotated, offset, originalSize)
Initializes SpriteFrame with Texture, rect, rotated, offset and originalSize in pixels.
Parameters:
{cc.Texture2D|HTMLImageElement} texture
{cc.Rect} rect
{Boolean} rotated
{cc.Point} offset
{cc.Size} originalSize
Returns:
{Boolean}

initWithTextureFilename(filename, rect, rotated, offset, originalSize)

Initializes a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
The originalSize is the size in pixels of the frame before being trimmed.

Parameters:
{string} filename
{cc.Rect} rect
{Boolean} rotated
{cc.Point} offset
{cc.Size} originalSize

{Boolean} isRotated()

return is rotated of SpriteFrame.

Returns:
{Boolean}

setOffset(offsets)
offset setter
Parameters:
{cc.Point} offsets

setOffsetInPixels(offsetInPixels)
set offset of the frame
Parameters:
{cc.Point} offsetInPixels

setOriginalSize(sizeInPixels)
set original size of the trimmed image
Parameters:
{cc.Size} sizeInPixels

setOriginalSizeInPixels(sizeInPixels)
set original size of the trimmed image
Parameters:
{cc.Size} sizeInPixels

setRect(rect)
set rect of the frame
Parameters:
{cc.Rect} rect

setRectInPixels(rectInPixels)
Parameters:
{cc.Rect} rectInPixels

setRotated(bRotated)
set SpriteFrame is rotated
Parameters:
{Boolean} bRotated

setTexture(texture)
set texture of the frame, the texture is retained
Parameters:
{cc.Texture2D|HTMLImageElement} texture

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 09 2013 07:51:53 GMT-0800 (PST)