Class cc.Scale9Sprite

Class Summary
Constructor Attributes Constructor Name and Description
 
A 9-slice sprite for cocos2d.

Method Summary

Class Detail

cc.Scale9Sprite()
A 9-slice sprite for cocos2d. 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
  • <static> cc.Scale9Sprite.create(file, rect, capInsets)
    Creates a 9-slice sprite with a texture file, a delimitation zone and with the specified cap insets.
    Parameters:
    file
    rect
    capInsets
    See:
    initWithFile:rect:centerRegion:
  • getColor()
    Color: conforms to CCRGBAProtocol protocol
  • {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}
  • getOpacity()
    Opacity: conforms to CCRGBAProtocol protocol
  • getOriginalSize()
    Original sprite's size.
  • 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.
    Parameters:
    file
    The name of the texture file.
    rect
    The rectangle that describes the sub-part of the texture that is the whole image. If the shape is the whole texture, set this to the texture's full rect.
    capInsets
    The values to use for the cap insets.
  • 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 intract. 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 intract. 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:
    capInsets
    The values to use for the cap insets.
  • 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
  • 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 oapcity 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
  • {boolean} textureLoaded()
    return texture is loaded
    Returns:
    {boolean}