Class cc.SpriteFrame
Extends
cc.Class.
Defined in: CCSpriteFrame.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A cc.SpriteFrame has: |
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
|
|
getRect()
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
|
|
setOriginalSizeInPixels(sizeInPixels)
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
|
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));
- Returns:
- {cc.SpriteFrame}
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}
//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}
- Returns:
- {cc.Point}
- Returns:
- {cc.Point}
- Returns:
- {cc.Size}
- Returns:
- {cc.Size}
- Returns:
- {cc.Rect}
- Returns:
- {cc.Rect}
- Returns:
- {cc.Texture2D|HTMLImageElement}
- Parameters:
- {cc.Texture2D|HTMLImageElement} texture
- {cc.Rect} rect
- {Boolean} rotated
- {cc.Point} offset
- {cc.Size} originalSize
- Returns:
- {Boolean}
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
return is rotated of SpriteFrame.
- Returns:
- {Boolean}
- Parameters:
- {cc.Point} offsets
- Parameters:
- {cc.Point} offsetInPixels
- Parameters:
- {cc.Size} sizeInPixels
- Parameters:
- {cc.Size} sizeInPixels
- Parameters:
- {cc.Rect} rect
- Parameters:
- {cc.Rect} rectInPixels
- Parameters:
- {Boolean} bRotated
- Parameters:
- {cc.Texture2D|HTMLImageElement} texture