Inherits from NSObject
Conforms to NSCopying
Declared in CCSpriteFrame.h

Overview

A CCSpriteFrame contains the texture and rectangle of the texture to be used by a CCSprite.

You can easily modify the sprite frame of a CCSprite using the following handy method:

CCSpriteFrame *frame = [CCSpriteFrame frameWithImageNamed:@“jump.png”]; [sprite setSpriteFrame:frame];

Properties

offset

Offset of the frame in points. If it is updated, then offsetInPixels will also be updated.

@property (nonatomic, readonly) CGPoint offset

Declared In

CCSpriteFrame.h

originalSize

Original size of the trimmed image in points.

@property (nonatomic, readonly) CGSize originalSize

Declared In

CCSpriteFrame.h

rect

Rectangle of the frame in points. If it is updated, then rectInPixels will also be updated.

@property (nonatomic, readonly) CGRect rect

Declared In

CCSpriteFrame.h

rotated

Is the frame rectangle is rotated.

@property (nonatomic, readonly) BOOL rotated

Declared In

CCSpriteFrame.h

texture

Texture of the frame.

@property (nonatomic, strong, readonly) CCTexture *texture

Declared In

CCSpriteFrame.h

textureFilename

Texture image file name, when created from a texture image.

@property (nonatomic, strong, readonly) NSString *textureFilename

Declared In

CCSpriteFrame.h

Class Methods

frameWithImageNamed:

Create and return a sprite frame object from the specified image name. On first attempt it will check CCSpriteFrameCache and if not available will then try and create from an image file of the same name.

+ (id)frameWithImageNamed:(NSString *)imageName

Parameters

imageName

Image name.

Return Value

The CCSpriteFrame Object.

Declared In

CCSpriteFrame.h

frameWithTexture:rectInPixels:rotated:offset:originalSize:

Create and return a sprite frame object from the specified texture, texture rectangle, rotation status, offset and originalSize values.

+ (id)frameWithTexture:(CCTexture *)texture rectInPixels:(CGRect)rect rotated:(BOOL)rotated offset:(CGPoint)offset originalSize:(CGSize)originalSize

Parameters

texture

Texture to use.

rect

Texture rectangle (in pixels) to use.

rotated

Is rectangle rotated?

offset

Offset (in pixels) to use.

originalSize

Original size (in pixels) before being trimmed.

Return Value

The CCSpriteFrame Object.

Declared In

CCSpriteFrame.h

frameWithTextureFilename:rectInPixels:rotated:offset:originalSize:

Create and return a sprite frame object from the specified texture file name, texture rectangle, rotation status, offset and originalSize values.

+ (id)frameWithTextureFilename:(NSString *)filename rectInPixels:(CGRect)rect rotated:(BOOL)rotated offset:(CGPoint)offset originalSize:(CGSize)originalSize

Parameters

filename

Image file name to use.

rect

Texture rectangle (in pixels) to use.

rotated

Is rectangle rotated?

offset

Offset (in pixels) to use.

originalSize

Original size (in pixels) before being trimmed.

Return Value

The CCSpriteFrame Object.

Declared In

CCSpriteFrame.h

Instance Methods

initWithTexture:rectInPixels:rotated:offset:originalSize:

Initializes and returns a sprite frame object from the specified texture, texture rectangle, rotation status, offset and originalSize values.

- (id)initWithTexture:(CCTexture *)texture rectInPixels:(CGRect)rect rotated:(BOOL)rotated offset:(CGPoint)offset originalSize:(CGSize)originalSize

Parameters

texture

Texture to use.

rect

Texture rectangle (in pixels) to use.

rotated

Is rectangle rotated?

offset

Offset (in pixels) to use.

originalSize

Original size (in pixels) before being trimmed.

Return Value

An initialized CCSpriteFrame Object.

Declared In

CCSpriteFrame.h

initWithTextureFilename:rectInPixels:rotated:offset:originalSize:

Initializes and returns a sprite frame object from the specified texture file name, texture rectangle, rotation status, offset and originalSize values.

- (id)initWithTextureFilename:(NSString *)filename rectInPixels:(CGRect)rect rotated:(BOOL)rotated offset:(CGPoint)offset originalSize:(CGSize)originalSize

Parameters

filename

Image file name to use.

rect

Texture rectangle (in pixels) to use.

rotated

Is rectangle rotated?

offset

Offset (in pixels) to use.

originalSize

Original size (in pixels) before being trimmed.

Return Value

An initialized CCSpriteFrame Object.

Declared In

CCSpriteFrame.h