10

Is it possible to run multiple ccactions on a sprite at the same time? For example, if I have a CCFadeIn, a CCScaleTo, and a CCRotateBy, all with the same duration, can I run all three on a sprite at the same time? The only thing I have found that does anything remotely close is CCSequence, and that's not what I want. Thanks!

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
eric.mitchell
  • 8,817
  • 12
  • 54
  • 92

2 Answers2

22

You don't need to use CCSpawn, just run these actions individually on the same sprite and they will run concurrently:

id fadeIn = [CCFadeIn actionWith…];
[sprite runAction:fadeIn];

id scale = [CCScaleTo actionWith…];
[sprite runAction:scale];

id rotate = [CCRotateBy actionWith…];
[sprite runAction:rotate];
CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • Seeing as how you wrote the book on Cocos2d is there any difference in terms of processing time that would make you want to use this instead of CCSpawn? – ScottPetit Nov 10 '11 at 15:19
  • 5
    Nothing that's relevant. CCSpawn is only intended to be used in a sequence of actions that should, at some point, "spawn" new actions that run in parallel with the action sequence and without having to use CCCallFunc and write another selector that adds these actions. For that case CCSpawn is convenient, in all other cases just call runAction multiple times. – CodeSmile Nov 10 '11 at 19:11
11

Just use CCSpawn, if you've used CCSequence you should automatically know how to use CCSpawn.

ScottPetit
  • 814
  • 5
  • 6