2011-10-02 7 views
2

以下を実行するCCAnimationHelperクラスを作成しました。あなたはそれにfileName、frameCount、およびDelayを与え、アニメーションを返します。私が知りたいのは、アニメーションのフレームをフレーム1で始めるのではなく、代わりにフレーム10で始めるということです。ここに私のコードでありませんcocos2dでアニメーションのフレームを設定する方法

// Creates an animation from sprite frames. 
+(CCAnimation*) animationWithFrame:(NSString*)frame frameCount:(int)frameCount delay:(float)delay 
{ 
// load the ship's animation frames as textures and create a sprite frame 
NSMutableArray* frames = [NSMutableArray arrayWithCapacity:frameCount]; 
for (int i = 1; i < frameCount; i++) 
{ 
    NSString* file = [NSString stringWithFormat:@"%@%i.png", frame, i]; 
    CCSpriteFrameCache* frameCache = [CCSpriteFrameCache sharedSpriteFrameCache]; 
    CCSpriteFrame* frame = [frameCache spriteFrameByName:file]; 
    [frames addObject:frame]; 
} 

// return an animation object from all the sprite animation frames 
return [CCAnimation animationWithFrames:frames delay:delay]; //Is there another method I should be using here to set the frame 
} 

答えて

1

ことないfuncionに建てられたが、あなたは単にあなたがしたいNSArrayのフレームから始まる、それをあなたのアニメーションを作成して渡すことができます。

CCAnimation *animation = [CCAnimation animation]; 
    NSArray *offset = [NSArray arrayWithObjects:frame3, frame4, nil]; 
    [animation initWithFrames:offset]; 
関連する問題