I just have a quick question. I am running through an array of images using CCAnimation to make a football spiral. Like so:
// load the football's animation frames as textures and create a sprite frame
frames = [[NSMutableArray alloc]initWithCapacity:3];
for (int i = 0; i < 10; i++)
{
NSString* file = [NSString stringWithFormat:@"Football%i.png", i];
CCTexture2D* texture = [[CCTextureCache sharedTextureCache] addImage:file];
CGSize texSize = texture.contentSize;
CGRect texRect = CGRectMake(0, 0, texSize.width, texSize.height);
CCSpriteFrame* frame = [CCSpriteFrame frameWithTexture:texture rect:texRect];
[frames addObject:frame];
}
// create an animation object from all the sprite animation frames
CCAnimation* anim = [CCAnimation animationWithFrames:frames delay:0.03f];
// run the animation by using the CCAnimate action
CCAnimate* animate = [CCAnimate actionWithAnimation:anim];
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:animate];
[self runAction:repeat];
This works really well, but I am wondering how I would create another animation with this same array that would make the football look like it slowly stops spinning? I know that delay:0.03f is controlling how fast the ball spirals, so is there a to some how make the delay slowly end up at 0.0f or is there another way to do it?
you can simply use
[animate setDuration:[animate getDuration] + 0.1]to increase the delay time. and you have to increase th delay time to make football look like it’s spinning slower. and after a while you just stop deactivate animate. if you want to create another animation using the anim frames you can call[CCAnimation AnimationWithFrames:[anim getFrames]]