0

I want to stop an action once my sprite gets to a certain rotation. For example:

CCAction *rotateUp = [CCRotateTo actionWithDuration:0.3 angle:-35];
[player runAction:rotateUp];

if (player.rotation == -35) {
    [player stopAction:rotateUp];
    [player runAction:[CCRotateTo actionWithDuration:0.5 angle:65]];
}

Once the player gets to the max rotation I want it to run a different action. But this isn't working. What can I do instead?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
ErikOhlin12
  • 83
  • 1
  • 10

1 Answers1

0

You cannot get Action output immediately. So it's good to give completion callback for that.

for ex. (in c++)

   CCAction *rotateUp = CCRotateTo::create(0.3f, -35f);
   CCCallFuncN *pCall = CCCallFuncN::create(callfunc_selector(<#_SELECTOR#>));

  player->runAction(CCSequence::create(rotateUp, pCall, NULL));

Here SELECTOR specified get called when rotation action gets completed. Just convert it in Obj C and try.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
Alok Rao
  • 162
  • 1
  • 12