Tom
Tom

Reputation: 47

How to set frame rate on CCAnimation

I have 5 sprite frames and i made them into an animation with a delay of 0.05 seconds between each frame. I then used CCAnimate to turn it into an action then ran it on a sprite.

CCAnimation *animation = [CCAnimation animationWithFrames:animationArray delay:0.05];
CCAnimate *animate = [CCAnimate actionWithDuration:10.0 animation:animation restoreOriginalFrame:YES];
[sprite runAction:animate];

The issue is that the frames have a delay of 2 seconds rather than 0.05. Is it possible to loop the animation with a frame ever 0.05 seconds for a duration of 10 seconds?

Upvotes: 0

Views: 754

Answers (1)

sergio
sergio

Reputation: 69047

I would suggest the following:

  1. make sure that the first argument to CCAnimate actionWithDuration matches the product of your delay` by the number of frames you have;

  2. use CCRepeat to repeat in a loop your basic animation:

    CCRepeat* repeat = [CCRepeat actionWithAction:animate times:5];
    [sprite runAction:repeat];
    

Upvotes: 1

Related Questions