Search code examples
objective-cxcodecocos2d-iphoneccsprite

How to apply two CCActions to two different CCSprites and run them in the same time on one CCLayer?


Actually the question is in the title. Anyway I would like to repeat it:
Question: How I could apply two different CCActions to two different CCSprites and run them in the same time on one CCLayer?

Thanks in advance!


Solution

  • The CCLayer has nothing to do with that. You just send the runAction message with the action one after another to have the actions start running at the same time:

    id action1 = [CCFadeOut actionWithDuration:1];
    [sprite1 runAction:action1];
    
    id action2 = [CCFadeIn actionWithDuration:1];
    [sprite2 runAction:action2];