CCScale9Sprite Class Reference
| Inherits from | CCNode |
| Conforms to | CCRGBAProtocol |
| Declared in | CCScale9Sprite.h |
Overview
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.
Tasks
Setting the Default Sizes
-
originalSizeOriginal sprite’s size.
property -
preferredSizePreferred sprite’s size. By default the preferred size is the original size.
property
3x3 Grid Attributes
-
capInsetsThe end-cap insets. On a non-resizeable sprite, this property is set to CGRectZero; the sprite does not use end caps and the entire sprite is subject to stretching.
property -
insetLeftSets the left side inset
property -
insetTopSets the top side inset
property -
insetRightSets the right side inset
property -
insetBottomSets the bottom side inset
property
RGBA Protocol Properties
-
opacityConforms to CCRGBAProtocol protocol.
property -
displayedOpacityConforms to CCRGBAProtocol (v2.1) protocol.
property -
colorConforms to CCRGBAProtocol protocol.
property -
displayedColorConforms to CCRGBAProtocol (v2.1) protocol.
property -
opacityModifyRGBConforms to CCRGBAProtocol protocol.
property -
cascadeColorEnabledConforms to CCRGBAProtocol (v2.1) protocol.
property -
cascadeOpacityEnabledConforms to CCRGBAProtocol (v2.1) protocol.
property
Create 9-Scale Sprites
-
– initWithFile: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 intract. It respects the anchorPoint too.
-
+ spriteWithFile:rect:capInsets:Creates a 9-slice sprite with a texture file, a delimitation zone and with the specified cap insets.
-
– initWithFile:rect:Initializes a 9-slice sprite with a texture file and a delimitation zone. The texture will be broken down into a 3×3 grid of equal blocks. 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.
-
+ spriteWithFile:rect:Creates a 9-slice sprite with a texture file and a delimitation zone. The texture will be broken down into a 3×3 grid of equal blocks.
-
– initWithFile:capInsets:Initializes a 9-slice sprite with a texture file 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.
-
+ spriteWithFile:capInsets:Creates a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks.
-
– initWithFile:Initializes a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks. 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.
-
+ spriteWithFile:Creates a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks.
-
– initWithSpriteFrame: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.
-
+ spriteWithSpriteFrame:capInsets:Creates a 9-slice sprite with an sprite frame and the centre of its zone. 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.
-
– initWithSpriteFrame:Initializes a 9-slice sprite with an sprite frame. 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.
-
+ spriteWithSpriteFrame:Creates a 9-slice sprite with an sprite frame. 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.
-
– initWithSpriteFrameName: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.
-
+ spriteWithSpriteFrameName:capInsets:Creates a 9-slice sprite with an sprite frame name and the centre of its zone. 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.
-
– initWithSpriteFrameName:Initializes a 9-slice sprite with an sprite frame name. 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.
-
+ spriteWithSpriteFrameName:Creates a 9-slice sprite with an sprite frame name. 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.
Modifying the 3x3 Grid
-
– resizableSpriteWithCapInsets: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.
Changing the Appearance
-
– setSpriteFrame:Sets the sprite frame used to display the 9-slice sprite.
Properties
capInsets
The end-cap insets. On a non-resizeable sprite, this property is set to CGRectZero; the sprite does not use end caps and the entire sprite is subject to stretching.
@property (nonatomic, assign) CGRect capInsetsDiscussion
The end-cap insets. On a non-resizeable sprite, this property is set to CGRectZero; the sprite does not use end caps and the entire sprite is subject to stretching.
Declared In
CCScale9Sprite.hcascadeColorEnabled
Conforms to CCRGBAProtocol (v2.1) protocol.
@property (nonatomic, getter=isCascadeColorEnabled) BOOL cascadeColorEnabledDiscussion
Conforms to CCRGBAProtocol (v2.1) protocol.
Declared In
CCScale9Sprite.hcascadeOpacityEnabled
Conforms to CCRGBAProtocol (v2.1) protocol.
@property (nonatomic, getter=isCascadeOpacityEnabled) BOOL cascadeOpacityEnabledDiscussion
Conforms to CCRGBAProtocol (v2.1) protocol.
Declared In
CCScale9Sprite.hcolor
Conforms to CCRGBAProtocol protocol.
@property (nonatomic, readwrite) ccColor3B colorDiscussion
Conforms to CCRGBAProtocol protocol.
Declared In
CCScale9Sprite.hdisplayedColor
Conforms to CCRGBAProtocol (v2.1) protocol.
@property (nonatomic, readonly) ccColor3B displayedColorDiscussion
Conforms to CCRGBAProtocol (v2.1) protocol.
Declared In
CCScale9Sprite.hdisplayedOpacity
Conforms to CCRGBAProtocol (v2.1) protocol.
@property (nonatomic, readonly) GLubyte displayedOpacityDiscussion
Conforms to CCRGBAProtocol (v2.1) protocol.
Declared In
CCScale9Sprite.hinsetBottom
Sets the bottom side inset
@property (nonatomic, assign) float insetBottomDiscussion
Sets the bottom side inset
Declared In
CCScale9Sprite.hinsetLeft
Sets the left side inset
@property (nonatomic, assign) float insetLeftDiscussion
Sets the left side inset
Declared In
CCScale9Sprite.hinsetRight
Sets the right side inset
@property (nonatomic, assign) float insetRightDiscussion
Sets the right side inset
Declared In
CCScale9Sprite.hinsetTop
Sets the top side inset
@property (nonatomic, assign) float insetTopDiscussion
Sets the top side inset
Declared In
CCScale9Sprite.hopacity
Conforms to CCRGBAProtocol protocol.
@property (nonatomic, readwrite) GLubyte opacityDiscussion
Conforms to CCRGBAProtocol protocol.
Declared In
CCScale9Sprite.hopacityModifyRGB
Conforms to CCRGBAProtocol protocol.
@property (nonatomic, getter=doesOpacityModifyRGB) BOOL opacityModifyRGBDiscussion
Conforms to CCRGBAProtocol protocol.
Declared In
CCScale9Sprite.hClass Methods
spriteWithFile:
Creates a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks.
+ (id)spriteWithFile:(NSString *)fileDiscussion
Creates a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks.
See Also
Declared In
CCScale9Sprite.hspriteWithFile:capInsets:
Creates a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks.
+ (id)spriteWithFile:(NSString *)file capInsets:(CGRect)capInsetsDiscussion
Creates a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks.
See Also
Declared In
CCScale9Sprite.hspriteWithFile:rect:
Creates a 9-slice sprite with a texture file and a delimitation zone. The texture will be broken down into a 3×3 grid of equal blocks.
+ (id)spriteWithFile:(NSString *)file rect:(CGRect)rectDiscussion
Creates a 9-slice sprite with a texture file and a delimitation zone. The texture will be broken down into a 3×3 grid of equal blocks.
See Also
Declared In
CCScale9Sprite.hspriteWithFile:rect:capInsets:
Creates a 9-slice sprite with a texture file, a delimitation zone and with the specified cap insets.
+ (id)spriteWithFile:(NSString *)file rect:(CGRect)rect capInsets:(CGRect)capInsetsDiscussion
Creates a 9-slice sprite with a texture file, a delimitation zone and with the specified cap insets.
Declared In
CCScale9Sprite.hspriteWithSpriteFrame:
Creates a 9-slice sprite with an sprite frame. 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.
+ (id)spriteWithSpriteFrame:(CCSpriteFrame *)spriteFrameDiscussion
Creates a 9-slice sprite with an sprite frame. 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.
See Also
Declared In
CCScale9Sprite.hspriteWithSpriteFrame:capInsets:
Creates a 9-slice sprite with an sprite frame and the centre of its zone. 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.
+ (id)spriteWithSpriteFrame:(CCSpriteFrame *)spriteFrame capInsets:(CGRect)capInsetsDiscussion
Creates a 9-slice sprite with an sprite frame and the centre of its zone. 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.
Declared In
CCScale9Sprite.hspriteWithSpriteFrameName:
Creates a 9-slice sprite with an sprite frame name. 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.
+ (id)spriteWithSpriteFrameName:(NSString *)spriteFrameNameDiscussion
Creates a 9-slice sprite with an sprite frame name. 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.
See Also
Declared In
CCScale9Sprite.hspriteWithSpriteFrameName:capInsets:
Creates a 9-slice sprite with an sprite frame name and the centre of its zone. 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.
+ (id)spriteWithSpriteFrameName:(NSString *)spriteFrameName capInsets:(CGRect)capInsetsDiscussion
Creates a 9-slice sprite with an sprite frame name and the centre of its zone. 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.
Declared In
CCScale9Sprite.hInstance Methods
initWithFile:
Initializes a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks. 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.
- (id)initWithFile:(NSString *)fileParameters
- file
The name of the texture file.
Discussion
Initializes a 9-slice sprite with a texture file. The whole texture will be broken down into a 3×3 grid of equal blocks. 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.
Declared In
CCScale9Sprite.hinitWithFile:capInsets:
Initializes a 9-slice sprite with a texture file 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.
- (id)initWithFile:(NSString *)file capInsets:(CGRect)capInsetsParameters
- file
The name of the texture file.
- capInsets
The values to use for the cap insets.
Discussion
Initializes a 9-slice sprite with a texture file 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.
Declared In
CCScale9Sprite.hinitWithFile:rect:
Initializes a 9-slice sprite with a texture file and a delimitation zone. The texture will be broken down into a 3×3 grid of equal blocks. 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.
- (id)initWithFile:(NSString *)file rect:(CGRect)rectParameters
- 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.
Discussion
Initializes a 9-slice sprite with a texture file and a delimitation zone. The texture will be broken down into a 3×3 grid of equal blocks. 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.
Declared In
CCScale9Sprite.hinitWithFile: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 intract. It respects the anchorPoint too.
- (id)initWithFile:(NSString *)file rect:(CGRect)rect capInsets:(CGRect)capInsetsParameters
- 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.
Discussion
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 intract. It respects the anchorPoint too.
Declared In
CCScale9Sprite.hinitWithSpriteFrame:
Initializes a 9-slice sprite with an sprite frame. 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.
- (id)initWithSpriteFrame:(CCSpriteFrame *)spriteFrameParameters
- spriteFrame
The sprite frame object.
Discussion
Initializes a 9-slice sprite with an sprite frame. 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.
Declared In
CCScale9Sprite.hinitWithSpriteFrame: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.
- (id)initWithSpriteFrame:(CCSpriteFrame *)spriteFrame capInsets:(CGRect)capInsetsParameters
- spriteFrame
The sprite frame object.
- capInsets
The values to use for the cap insets.
Discussion
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.
Declared In
CCScale9Sprite.hinitWithSpriteFrameName:
Initializes a 9-slice sprite with an sprite frame name. 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.
- (id)initWithSpriteFrameName:(NSString *)spriteFrameNameParameters
- spriteFrameName
The sprite frame name.
Discussion
Initializes a 9-slice sprite with an sprite frame name. 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.
Declared In
CCScale9Sprite.hinitWithSpriteFrameName: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.
- (id)initWithSpriteFrameName:(NSString *)spriteFrameName capInsets:(CGRect)capInsetsParameters
- spriteFrameName
The sprite frame name.
- capInsets
The values to use for the cap insets.
Discussion
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.
Declared In
CCScale9Sprite.hresizableSpriteWithCapInsets:
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.
- (CCScale9Sprite *)resizableSpriteWithCapInsets:(CGRect)capInsetsParameters
- capInsets
The values to use for the cap insets.
Discussion
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.
Declared In
CCScale9Sprite.h