CCSprite Class Reference

#import <CCSprite.h>

Inherits CCNode, CCFrameProtocol-p, CCRGBAProtocol-p, and CCTextureProtocol-p.

Inherited by CCLabel.

Collaboration diagram for CCSprite:
Collaboration graph
[legend]

List of all members.

Public Member Functions

(id) - initWithTexture:
(id) - initWithTexture:rect:
(id) - initWithSpriteFrame:
(id) - initWithSpriteFrameName:
(id) - initWithFile:
(id) - initWithFile:rect:
(id) - initWithCGImage:
(id) - initWithCGImage:key:
(id) - initWithSpriteSheet:rect:
(void) - updateTransform
(void) - setTextureRect:
(void) - useSelfRender
(void) - useSpriteSheetRender:

Static Public Member Functions

(id) + spriteWithTexture:
(id) + spriteWithTexture:rect:
(id) + spriteWithTexture:rect:offset:
(id) + spriteWithSpriteFrame:
(id) + spriteWithSpriteFrameName:
(id) + spriteWithFile:
(id) + spriteWithFile:rect:
(id) + spriteWithCGImage:
(id) + spriteWithCGImage:key:
(id) + spriteWithSpriteSheet:rect:

Properties

BOOL dirty
ccV3F_C4B_T2F_Quad quad
NSUInteger atlasIndex
CGRect textureRect
BOOL flipX
BOOL flipY
GLubyte opacity
ccColor3B color
BOOL usesSpriteSheet
CCTextureAtlastextureAtlas
CCSpriteSheetspriteSheet
ccHonorParentTransform honorParentTransform
CGPoint offsetPosition
ccBlendFunc blendFunc

Detailed Description

CCSprite is a CCNode object that implements the CCFrameProtocol and CCRGBAProtocol protocols.

If the parent is a CCSpriteSheet then the following features/limitations are valid

If the parent is an standard CCNode, then CCSprite behaves like any other CCNode:

Definition at line 67 of file CCSprite.h.


Member Function Documentation

- (id) initWithCGImage:  

Initializes an sprite with a CGImageRef

Deprecated:
Use spriteWithCGImage:key: instead. Will be removed in v1.0 final
- (id) initWithCGImage: (CGImageRef)  image
key: (NSString *)  key 

Initializes an sprite with a CGImageRef and a key The key is used by the CCTextureCache to know if a texture was already created with this CGImage. For example, a valid key is: "sprite_frame_01". If key is nil, then a new texture will be created each time by the CCTextureCache.

Since:
v0.99.0
- (id) initWithFile: (NSString *)  filename  

Initializes an sprite with an image filename. The rect used will be the size of the image. The offset will be (0,0).

- (id) initWithFile: (NSString *)  filename
rect: (CGRect)  rect 

Initializes an sprite with an image filename, and a rect. The offset will be (0,0).

- (id) initWithSpriteFrame: (CCSpriteFrame *)  spriteFrame  

Initializes an sprite with an sprite frame.

- (id) initWithSpriteFrameName: (NSString *)  spriteFrameName  

Initializes an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. If the CCSpriteFrame doesn't exist it will raise an exception.

Since:
v0.9
- (id) initWithSpriteSheet: (CCSpriteSheet *)  spritesheet
rect: (CGRect)  rect 

Initializes an sprite with an CCSpriteSheet and a rect

- (id) initWithTexture: (CCTexture2D *)  texture  

Initializes an sprite with a texture. The rect used will be the size of the texture. The offset will be (0,0).

- (id) initWithTexture: (CCTexture2D *)  texture
rect: (CGRect)  rect 

Initializes an sprite with a texture and a rect. The offset will be (0,0).

- (void) setTextureRect: (CGRect)  rect  

updates the texture rect of the CCSprite.

+ (id) spriteWithCGImage:  

Creates an sprite with a CGImageRef.

Deprecated:
Use spriteWithCGImage:key: instead. Will be removed in v1.0 final
+ (id) spriteWithCGImage: (CGImageRef)  image
key: (NSString *)  key 

Creates an sprite with a CGImageRef and a key. The key is used by the CCTextureCache to know if a texture was already created with this CGImage. For example, a valid key is: "sprite_frame_01". If key is nil, then a new texture will be created each time by the CCTextureCache.

Since:
v0.99.0
+ (id) spriteWithFile: (NSString *)  filename  

Creates an sprite with an image filename. The rect used will be the size of the image. The offset will be (0,0).

+ (id) spriteWithFile: (NSString *)  filename
rect: (CGRect)  rect 

Creates an sprite with an image filename and a rect. The offset will be (0,0).

+ (id) spriteWithSpriteFrame: (CCSpriteFrame *)  spriteFrame  

Creates an sprite with an sprite frame.

+ (id) spriteWithSpriteFrameName: (NSString *)  spriteFrameName  

Creates an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. If the CCSpriteFrame doesn't exist it will raise an exception.

Since:
v0.9
+ (id) spriteWithSpriteSheet: (CCSpriteSheet *)  spritesheet
rect: (CGRect)  rect 

Creates an sprite with an CCSpriteSheet and a rect

+ (id) spriteWithTexture: (CCTexture2D *)  texture  

Creates an sprite with a texture. The rect used will be the size of the texture. The offset will be (0,0).

+ (id) spriteWithTexture: (CCTexture2D *)  texture
rect: (CGRect)  rect 

Creates an sprite with a texture and a rect. The offset will be (0,0).

+ (id) spriteWithTexture: (CCTexture2D *)  texture
rect: (CGRect)  rect
offset: (CGPoint)  offset 

Creates an sprite with a texture, a rect and offset.

- (void) updateTransform  

updates the quad according the the rotation, position, scale values.

- (void) useSelfRender  

tell the sprite to use self-render.

Since:
v0.99.0
- (void) useSpriteSheetRender: (CCSpriteSheet *)  spriteSheet  

tell the sprite to use sprite sheet render.

Since:
v0.99.0

Property Documentation

- (NSUInteger) atlasIndex [read, write, assign]

The index used on the TextureATlas. Don't modify this value unless you know what you are doing

Definition at line 123 of file CCSprite.h.

- (ccBlendFunc) blendFunc [read, write, assign]

conforms to CCTextureProtocol protocol

Definition at line 163 of file CCSprite.h.

- (ccColor3B) color [read, assign]

RGB colors: conforms to CCRGBAProtocol protocol

Definition at line 145 of file CCSprite.h.

- (BOOL) dirty [read, write, assign]

whether or not the Sprite needs to be updated in the Atlas

Definition at line 119 of file CCSprite.h.

- (BOOL) flipX [read, write, assign]

whether or not the sprite is flipped horizontally. It only flips the texture of the sprite, and not the texture of the sprite's children. Also, flipping the texture doesn't alter the anchorPoint. If you want to flip the anchorPoint too, and/or to flip the children too use:

sprite.scaleX *= -1;

Definition at line 133 of file CCSprite.h.

- (BOOL) flipY [read, write, assign]

whether or not the sprite is flipped vertically\ It only flips the texture of the sprite, and not the texture of the sprite's children. Also, flipping the texture doesn't alter the anchorPoint. If you want to flip the anchorPoint too, and/or to flip the children too use:

sprite.scaleY *= -1;

Definition at line 141 of file CCSprite.h.

- (ccHonorParentTransform) honorParentTransform [read, write, assign]

whether or not to transform according to its parent transfomrations. Useful for health bars. eg: Don't rotate the health bar, even if the parent rotates. IMPORTANT: Only valid if it is rendered using an CCSpriteSheet.

Since:
v0.99.0

Definition at line 157 of file CCSprite.h.

- (CGPoint) offsetPosition [read, write, assign]

offset position of the sprite. Calculated automatically by editors like Zwoptex.

Since:
v0.99.0

Definition at line 161 of file CCSprite.h.

- (GLubyte) opacity [read, assign]

opacity: conforms to CCRGBAProtocol protocol

Definition at line 143 of file CCSprite.h.

- (ccV3F_C4B_T2F_Quad) quad [read, assign]

the quad (tex coords, vertex coords and color) information

Definition at line 121 of file CCSprite.h.

- (CCSpriteSheet*) spriteSheet [read, write, assign]

weak reference to the CCSpriteSheet that renders the CCSprite

Definition at line 151 of file CCSprite.h.

- (CCTextureAtlas*) textureAtlas [read, write, assign]

weak reference of the CCTextureAtlas used when the sprite is rendered using a CCSpriteSheet

Definition at line 149 of file CCSprite.h.

- (CGRect) textureRect [read, assign]

returns the rect of the CCSprite

Definition at line 125 of file CCSprite.h.

- (BOOL) usesSpriteSheet [read, write, assign]

whether or not the Sprite is rendered using a CCSpriteSheet

Definition at line 147 of file CCSprite.h.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Properties Defines

cocos2d for iPhone 0.99.0