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]; 
관련 문제