Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have created a spiraling animation for a football. I want to be able to run it on 2 sprites simultaneously.

This is what I have done:

CCAnimation* footballAnim = [CCAnimation animationWithFrame:@"Football" frameCount:60 delay:0.005f];
spiral = [CCAnimate actionWithAnimation:footballAnim];
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:spiral];
[Sprite1 runAction: repeat];
[Sprite2 runAction: repeat];

However, the action is only run on the first sprite. What am I doing wrong?

share|improve this question

1 Answer 1

Actions (sadly) can't be re-used or run multiple times. Instead you'll have to instantiate two actions or copy an existing one.

Something like this should work:

[Sprite1 runAction: [repeat copy]];
[Sprite2 runAction: repeat];
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.