Class ccui.Scale9Sprite
- Defined in: UIScale9Sprite.js
- Extends cc.Node
Constructor Attributes | Constructor Name and Description |
---|---|
A 9-slice sprite for cocos2d UI. |
Method Summary
Class Detail
ccui.Scale9Sprite()
A 9-slice sprite for cocos2d UI.
9-slice scaling allows you to specify how scaling is applied
to specific areas of a sprite. With 9-slice scaling (3x3 grid),
you can ensure that the sprite does not become distorted when
scaled.
- See:
- http://yannickloriot.com/library/ios/cccontrolextension/Classes/CCScale9Sprite.html
Field Detail
{cc.Rect}
capInsets
- The cap insets of the 9-slice sprite
{Number}
insetBottom
- The bottom inset of the 9-slice sprite
{Number}
insetLeft
- The left inset of the 9-slice sprite
{Number}
insetRight
- The right inset of the 9-slice sprite
{Number}
insetTop
- The top inset of the 9-slice sprite
{cc.Size}
preferredSize
- The preferred size of the 9-slice sprite
Method Detail
-
addLoadedEventListener(callback, target)add texture loaded event listener
- Parameters:
- {Function} callback
- {Object} target
-
Creates a 9-slice sprite with a texture file, a delimitation zone and with the specified cap insets.
- Parameters:
- {String|cc.SpriteFrame} file
- file name of texture or a cc.Sprite object
- {cc.Rect} rect
- the rect of the texture
- {cc.Rect} capInsets
- the cap insets of ccui.Scale9Sprite
- Deprecated:
- since v3.0, please use new ccui.Scale9Sprite(file, rect, capInsets) instead.
- Returns:
- {ccui.Scale9Sprite}
-
create a ccui.Scale9Sprite with Sprite frame.
- Parameters:
- {cc.SpriteFrame} spriteFrame
- {cc.Rect} capInsets
- Deprecated:
- since v3.0, please use "new ccui.Scale9Sprite(spriteFrame, capInsets)" instead.
- Returns:
- {ccui.Scale9Sprite}
-
<static> {Scale9Sprite} ccui.Scale9Sprite.createWithSpriteFrameName(spriteFrameName, capInsets)create a ccui.Scale9Sprite with a Sprite frame name
- Parameters:
- {string} spriteFrameName
- {cc.Rect} capInsets
- Deprecated:
- since v3.0, please use "new ccui.Scale9Sprite(spriteFrameName, capInsets)" instead.
- Returns:
- {Scale9Sprite}
-
{Scale9Sprite} ctor(file, rect, capInsets)Constructor function. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
- Parameters:
- {string|cc.SpriteFrame} file
- file name of texture or a SpriteFrame
- {cc.Rect} rect
- {cc.Rect} capInsets
- Returns:
- {Scale9Sprite}
-
{number} getInsetBottom()Gets the bottom side inset
- Returns:
- {number}
-
{number} getInsetLeft()Gets the left side inset
- Returns:
- {number}
-
{number} getInsetRight()Gets the right side inset
- Returns:
- {number}
-
{number} getInsetTop()Gets the top side inset
- Returns:
- {number}
-
getOriginalSize()Original sprite's size.
-
{boolean} init()Initializes a ccui.Scale9Sprite. please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
- Returns:
- {boolean}
-
{boolean} initWithBatchNode(batchNode, rect, rotated, capInsets)Initializes a 9-slice sprite with a SpriteBatchNode.
- Parameters:
- {cc.SpriteBatchNode} batchNode
- {cc.Rect} rect
- {boolean|cc.Rect} rotated
- {cc.Rect} capInsets Optional
- Returns:
- {boolean}
-
initWithFile(file, rect, capInsets)Initializes a 9-slice sprite with a texture file, a delimitation zone and with the specified cap insets. Once the sprite is created, you can then call its "setContentSize:" method to resize the sprite will all it's 9-slice goodness intact. It respects the anchorPoint too.
-
initWithSpriteFrame(spriteFrame, capInsets)Initializes a 9-slice sprite with an sprite frame and with the specified cap insets. Once the sprite is created, you can then call its "setContentSize:" method to resize the sprite will all it's 9-slice goodness interact. It respects the anchorPoint too.
- Parameters:
- spriteFrame
- The sprite frame object.
- capInsets
- The values to use for the cap insets.
-
initWithSpriteFrameName(spriteFrameName, capInsets)Initializes a 9-slice sprite with an sprite frame name and with the specified cap insets. Once the sprite is created, you can then call its "setContentSize:" method to resize the sprite will all it's 9-slice goodness interact. It respects the anchorPoint too.
- Parameters:
- spriteFrameName
- The sprite frame name.
- capInsets
- The values to use for the cap insets.
-
isOpacityModifyRGB()returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity);
- Since:
- v0.8
-
resizableSpriteWithCapInsets(capInsets)Creates and returns a new sprite object with the specified cap insets. You use this method to add cap insets to a sprite or to change the existing cap insets of a sprite. In both cases, you get back a new image and the original sprite remains untouched.
- Parameters:
- {cc.Rect} capInsets
- The values to use for the cap insets.
-
setColor(color)Color: conforms to CCRGBAProtocol protocol
- Parameters:
- color
-
setContentSize(size, height)Sets the untransformed size of the Scale9Sprite.
- Parameters:
- {cc.Size|Number} size
- The untransformed size of the Scale9Sprite or The untransformed size's width of the Scale9Sprite.
- {Number} height Optional
- The untransformed size's height of the Scale9Sprite.
-
setInsetBottom(insetBottom)Sets the bottom side inset
- Parameters:
- {number} insetBottom
-
setInsetLeft(insetLeft)Sets the left side inset
- Parameters:
- {Number} insetLeft
-
setInsetRight(insetRight)Sets the right side inset
- Parameters:
- {Number} insetRight
-
setInsetTop(insetTop)Sets the top side inset
- Parameters:
- {Number} insetTop
-
setOpacity(opacity)Opacity: conforms to CCRGBAProtocol protocol
- Parameters:
- opacity
-
setOpacityModifyRGB(value)sets the premultipliedAlphaOpacity property. If set to NO then opacity will be applied as: glColor(R,G,B,opacity); If set to YES then opacity will be applied as: glColor(opacity, opacity, opacity, opacity ); Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO
- Parameters:
- value
- Since:
- v0.8
-
setSpriteFrame(spriteFrame)set the sprite frame of ccui.Scale9Sprite
- Parameters:
- {cc.SpriteFrame} spriteFrame
-
{boolean} textureLoaded()return texture is loaded
- Returns:
- {boolean}
-
{boolean} updateWithBatchNode(batchNode, originalRect, rotated, capInsets)Update the scale9Sprite with a SpriteBatchNode.
- Parameters:
- {cc.SpriteBatchNode} batchNode
- {cc.Rect} originalRect
- {boolean} rotated
- {cc.Rect} capInsets
- Returns:
- {boolean}