[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"runningman_coords.plist"];
// I presume this is where you load the first sprite?
CCSprite *sprite = [CCSprite spriteWithSpriteFrameName:@"runningman1.png"];
sprite.position = ccp( s.width/2-80, s.height/2);
CCSpriteSheet *spritesheet = [CCSpriteSheet spriteSheetWithFile:@"runningman_textures.png"];
[spritesheet addChild:sprite];
[self addChild:spritesheet];
NSMutableArray *animFrames = [NSMutableArray array];
for(int i = 1; i < style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"runningman%d.png",i]];
[animFrames addObject:frame];
}
CCAnimation *animation = [CCAnimation animationWithName:@"run" delay:0.2f frames:animFrames];
[sprite runAction:[CCRepeatForever actionWithAction: [CCAnimate actionWithAnimation:animation restoreOriginalFrame:NO] ]];
No comments:
Post a Comment