|
cocos2d-iphone
1.0.1
Improved Cocos2D API Reference (iOS version) for Kobold2D developers
|
#include <CCSprite.h>
Inheritance diagram for CCSprite:
Collaboration diagram for CCSprite:Public Member Functions | |
| id | initWithTexture: (CCTexture2D *texture) |
| id | initWithTexture:rect: (CCTexture2D *texture,[rect] CGRect rect) |
| id | initWithSpriteFrame: (CCSpriteFrame *spriteFrame) |
| id | initWithSpriteFrameName: (NSString *spriteFrameName) |
| id | initWithFile: (NSString *filename) |
| id | initWithFile:rect: (NSString *filename,[rect] CGRect rect) |
| id | initWithCGImage:key: (CGImageRef image,[key] NSString *key) |
| id | initWithBatchNode:rect: (CCSpriteBatchNode *batchNode,[rect] CGRect rect) |
| id | initWithBatchNode:rectInPixels: (CCSpriteBatchNode *batchNode,[rectInPixels] CGRect rect) |
| void | updateTransform () |
| void | setTextureRect: (CGRect rect) |
| void | setTextureRectInPixels:rotated:untrimmedSize: (CGRect rect,[rotated] BOOL rotated,[untrimmedSize] CGSize size) |
| void | useSelfRender () |
| void | useBatchNode: (CCSpriteBatchNode *batchNode) |
| void | setDisplayFrame: (CCSpriteFrame *newFrame) |
| BOOL | isFrameDisplayed: (CCSpriteFrame *frame) |
| CCSpriteFrame * | displayedFrame () |
| void | setDisplayFrameWithAnimationName:index: (NSString *animationName,[index] int frameIndex) |
Static Public Member Functions | |
| id | spriteWithTexture: (CCTexture2D *texture) |
| id | spriteWithTexture:rect: (CCTexture2D *texture,[rect] CGRect rect) |
| id | spriteWithSpriteFrame: (CCSpriteFrame *spriteFrame) |
| id | spriteWithSpriteFrameName: (NSString *spriteFrameName) |
| id | spriteWithFile: (NSString *filename) |
| id | spriteWithFile:rect: (NSString *filename,[rect] CGRect rect) |
| id | spriteWithCGImage:key: (CGImageRef image,[key] NSString *key) |
| id | spriteWithBatchNode:rect: (CCSpriteBatchNode *batchNode,[rect] CGRect rect) |
Public Attributes | |
| void(* | updateMethod )(id, SEL) |
Protected Attributes | |
| CCTextureAtlas * | textureAtlas_ |
| NSUInteger | atlasIndex_ |
| CCSpriteBatchNode * | batchNode_ |
| ccHonorParentTransform | honorParentTransform_ |
| BOOL | dirty_ |
| BOOL | recursiveDirty_ |
| BOOL | hasChildren_ |
| ccBlendFunc | blendFunc_ |
| CCTexture2D * | texture_ |
| BOOL | usesBatchNode_ |
| CGRect | rect_ |
| CGRect | rectInPixels_ |
| BOOL | rectRotated_ |
| CGPoint | offsetPositionInPixels_ |
| CGPoint | unflippedOffsetPositionFromCenter_ |
| ccV3F_C4B_T2F_Quad | quad_ |
| GLubyte | opacity_ |
| ccColor3B | color_ |
| ccColor3B | colorUnmodified_ |
| BOOL | opacityModifyRGB_ |
| BOOL | flipX_ |
| BOOL | flipY_ |
Properties | |
| BOOL | dirty |
| ccV3F_C4B_T2F_Quad | quad |
| NSUInteger | atlasIndex |
| CGRect | textureRect |
| BOOL | textureRectRotated |
| BOOL | flipX |
| BOOL | flipY |
| GLubyte | opacity |
| ccColor3B | color |
| BOOL | usesBatchNode |
| CCTextureAtlas * | textureAtlas |
| CCSpriteBatchNode * | batchNode |
| ccHonorParentTransform | honorParentTransform |
| CGPoint | offsetPositionInPixels |
| ccBlendFunc | blendFunc |
CCSprite is a 2d image ( http://en.wikipedia.org/wiki/Sprite_(computer_graphics) )
CCSprite can be created with an image, or with a sub-rectangle of an image.
If the parent or any of its ancestors is a CCSpriteBatchNode then the following features/limitations are valid
If the parent is an standard CCNode, then CCSprite behaves like any other CCNode:
The default anchorPoint in CCSprite is (0.5, 0.5).
| CCSpriteFrame* CCSprite::displayedFrame | ( | ) | [virtual] |
returns the current displayed frame.
| id CCSprite::initWithBatchNode:rect: | ( | CCSpriteBatchNode * | batchNode, |
| [rect] CGRect | rect | ||
| ) | [virtual] |
Initializes an sprite with an CCSpriteBatchNode and a rect in points
| id CCSprite::initWithBatchNode:rectInPixels: | ( | CCSpriteBatchNode * | batchNode, |
| [rectInPixels] CGRect | rect | ||
| ) | [virtual] |
Initializes an sprite with an CCSpriteBatchNode and a rect in pixels
| id CCSprite::initWithCGImage:key: | ( | CGImageRef | image, |
| [key] NSString * | key | ||
| ) | [virtual] |
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.
| id CCSprite::initWithFile: | ( | NSString * | filename | ) | [virtual] |
Initializes an sprite with an image filename. The rect used will be the size of the image. The offset will be (0,0).
| id CCSprite::initWithFile:rect: | ( | NSString * | filename, |
| [rect] CGRect | rect | ||
| ) | [virtual] |
Initializes an sprite with an image filename, and a rect. The offset will be (0,0).
| id CCSprite::initWithSpriteFrame: | ( | CCSpriteFrame * | spriteFrame | ) | [virtual] |
Initializes an sprite with an sprite frame.
| id CCSprite::initWithSpriteFrameName: | ( | NSString * | spriteFrameName | ) | [virtual] |
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.
| id CCSprite::initWithTexture: | ( | CCTexture2D * | texture | ) | [virtual] |
Initializes an sprite with a texture. The rect used will be the size of the texture. The offset will be (0,0).
| id CCSprite::initWithTexture:rect: | ( | CCTexture2D * | texture, |
| [rect] CGRect | rect | ||
| ) | [virtual] |
Initializes an sprite with a texture and a rect in points. The offset will be (0,0).
| BOOL CCSprite::isFrameDisplayed: | ( | CCSpriteFrame * | frame | ) | [virtual] |
returns whether or not a CCSpriteFrame is being displayed
| void CCSprite::setDisplayFrame: | ( | CCSpriteFrame * | newFrame | ) | [virtual] |
sets a new display frame to the CCSprite.
| void CCSprite::setDisplayFrameWithAnimationName:index: | ( | NSString * | animationName, |
| [index] int | frameIndex | ||
| ) | [virtual] |
changes the display frame with animation name and index. The animation name will be get from the CCAnimationCache
| void CCSprite::setTextureRect: | ( | CGRect | rect | ) | [virtual] |
updates the texture rect of the CCSprite in points.
| void CCSprite::setTextureRectInPixels:rotated:untrimmedSize: | ( | CGRect | rect, |
| [rotated] BOOL | rotated, | ||
| [untrimmedSize] CGSize | size | ||
| ) | [virtual] |
updates the texture rect, rectRotated and untrimmed size of the CCSprite in pixels
| id CCSprite::spriteWithBatchNode:rect: | ( | CCSpriteBatchNode * | batchNode, |
| [rect] CGRect | rect | ||
| ) | [static, virtual] |
Creates an sprite with an CCBatchNode and a rect
| id CCSprite::spriteWithCGImage:key: | ( | CGImageRef | image, |
| [key] NSString * | key | ||
| ) | [static, virtual] |
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.
| id CCSprite::spriteWithFile: | ( | NSString * | filename | ) | [static, virtual] |
Creates an sprite with an image filename. The rect used will be the size of the image. The offset will be (0,0).
| id CCSprite::spriteWithFile:rect: | ( | NSString * | filename, |
| [rect] CGRect | rect | ||
| ) | [static, virtual] |
Creates an sprite with an image filename and a rect. The offset will be (0,0).
| id CCSprite::spriteWithSpriteFrame: | ( | CCSpriteFrame * | spriteFrame | ) | [static, virtual] |
Creates an sprite with an sprite frame.
| id CCSprite::spriteWithSpriteFrameName: | ( | NSString * | spriteFrameName | ) | [static, virtual] |
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.
| id CCSprite::spriteWithTexture: | ( | CCTexture2D * | texture | ) | [static, virtual] |
Creates an sprite with a texture. The rect used will be the size of the texture. The offset will be (0,0).
| id CCSprite::spriteWithTexture:rect: | ( | CCTexture2D * | texture, |
| [rect] CGRect | rect | ||
| ) | [static, virtual] |
Creates an sprite with a texture and a rect. The offset will be (0,0).
| void CCSprite::updateTransform | ( | ) | [virtual] |
updates the quad according the the rotation, position, scale values.
| void CCSprite::useBatchNode: | ( | CCSpriteBatchNode * | batchNode | ) | [virtual] |
tell the sprite to use sprite batch node
| void CCSprite::useSelfRender | ( | ) | [virtual] |
tell the sprite to use self-render.
NSUInteger CCSprite::atlasIndex [read, write, assign] |
The index used on the TextureAtlas. Don't modify this value unless you know what you are doing
CCSpriteBatchNode* CCSprite::batchNode [read, write, assign] |
weak reference to the CCSpriteBatchNode that renders the CCSprite
ccBlendFunc CCSprite::blendFunc [read, write, assign] |
conforms to CCTextureProtocol protocol
ccColor3B CCSprite::color [read, write, assign] |
RGB colors: conforms to CCRGBAProtocol protocol
BOOL CCSprite::dirty [read, write, assign] |
whether or not the Sprite needs to be updated in the Atlas
BOOL CCSprite::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;
BOOL CCSprite::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;
ccHonorParentTransform CCSprite::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 CCSpriteBatchNode.
CGPoint CCSprite::offsetPositionInPixels [read, assign] |
offset position in pixels of the sprite in points. Calculated automatically by editors like Zwoptex.
GLubyte CCSprite::opacity [read, write, assign] |
opacity: conforms to CCRGBAProtocol protocol
ccV3F_C4B_T2F_Quad CCSprite::quad [read, assign] |
the quad (tex coords, vertex coords and color) information
CCTextureAtlas* CCSprite::textureAtlas [read, write, assign] |
weak reference of the CCTextureAtlas used when the sprite is rendered using a CCSpriteBatchNode
CGRect CCSprite::textureRect [read, assign] |
returns the rect of the CCSprite in points
BOOL CCSprite::textureRectRotated [read, assign] |
returns whether or not the texture rectangle is rotated
BOOL CCSprite::usesBatchNode [read, write, assign] |
whether or not the Sprite is rendered using a CCSpriteBatchNode