// 创建一个英雄
CCSprite *heroSprite = [CCSprite spriteWithSpriteFrameName:@"Hero-Default.png"];
heroSprite.position = ccp(200,200);
[self addChild:heroSprite];
NSMutableArray*animationFrames = [NSMutableArrayarrayWithCapacity:2];
for(inti =1; i <5; i++) {
NSString*fileName = [NSStringstringWithFormat:@"Hero-Fly-%d.png",i];
CCSpriteFrame*frame = [[CCSpriteFrameCachesharedSpriteFrameCache]spriteFrameByName:fileName];
[animationFramesaddObject:frame];
}
CCAnimation *animation = [CCAnimation animationWithFrames:animationFrames delay:0.2f];
CCAnimate *animate = [CCAnimate actionWithAnimation:animation restoreOriginalFrame:NO];
[heroSprite runAction:animate];
//为英雄插入翅膀,开始飞行 v2.1
CCAnimation *animation = [CCAnimation animationWithSpriteFrames:animationFrames delay:delay];
animation.restoreOriginalFrame = NO;
CCAnimate *animate = [CCAnimate actionWithAnimation:animation];
return animate;