Cocos2D – Animation with Defined Frames

To animate a sprite with a set number of frames and then stop:

CCAnimation *anim = anim = [[CCAnimation alloc] initWithName:@"idle" delay:0.1f];
[anim addFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"frame_1.png"]];
[anim addFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"frame_2.png"]];
[anim addFrame:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName: @"frame_3.png"]];
id action = [CCRepeat actionWithAction:[CCAnimate actionWithAnimation:anim restoreOriginalFrame:NO] times:1];
[self runAction:action];