Class cc.SpriteFrame#ctor
- Defined in: CCSpriteFrame.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
cc.SpriteFrame#ctor(filename, rect, rotated, offset, originalSize)
Create a cc.SpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. |
Class Detail
cc.SpriteFrame#ctor(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.
// 1.Create a cc.SpriteFrame with image path
var frame1 = new cc.SpriteFrame("res/grossini_dance.png",cc.rect(0,0,90,128));
var frame2 = new cc.SpriteFrame("res/grossini_dance.png",cc.rect(0,0,90,128),false,0,cc.size(90,128));
// 2.Create a cc.SpriteFrame with a texture, rect, rotated, offset and originalSize in pixels.
var texture = cc.textureCache.addImage("res/grossini_dance.png");
var frame1 = new cc.SpriteFrame(texture, cc.rect(0,0,90,128));
var frame2 = new cc.SpriteFrame(texture, cc.rect(0,0,90,128),false,0,cc.size(90,128));
- Parameters:
- {String|cc.Texture2D} filename
- {cc.Rect} rect
- if parameters' length equal 2, rect in points, else rect in pixels
- {Boolean} rotated
- {cc.Point} offset
- {cc.Size} originalSize