+(void)playSequenceFrame:(NSString *)firstFrameName Times:(int)times Delay:(float)delay Sprite:(CCSprite *)aSprite ToHead:(BOOL)ToHead
{
NSString * aString = [firstFrameName substringToIndex:[firstFrameName length]-4];
aString = [aString substringFromIndex:[aString length]-1];
int firstPicNum = [aString intValue];
NSMutableArray *animFrames1 = [NSMutableArray array];
int frameNum = [PersonalApi getSequenceFrameNum:firstFrameName];
firstFrameName = [firstFrameName substringToIndex:[firstFrameName length]-5];
for(int i = firstPicNum; i <=frameNum; i++)
{
CCSpriteFrame *frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"%@%d.png",firstFrameName,i]];
[animFrames1 addObject:frame];
}
CCAnimation *animation = [CCAnimation animationWithSpriteFrames:animFrames1 delay:delay];
CCAnimate* animate = [CCAnimate actionWithAnimation:animation];
CCSequence *seq = [CCSequence actions:animate,nil];
if (ToHead == YES)
{
animation.restoreOriginalFrame = YES;//回到第一帧的图的方法
}
id repeat;
if (times == -1)
{
repeat = [CCRepeatForever actionWithAction:seq];
[aSprite runAction:[CCSequence actions:repeat,nil]];
}
else
{
repeat = [CCRepeat actionWithAction:seq times:times];
id acf = [CCCallFunc actionWithTarget:[aSprite parent] selector:@selector(animeFinish)]; //检测不监测
[aSprite runAction:[CCSequence actions:repeat,acf,nil]];
}
}