cocos2d-iphoneccaction

Cocos2D ignoring a CCAction


I'm trying to run two CCMoveTo actions on my sprite like this:

[mySprite runAction:moveUp];
[mySprite runAction:moveRight];

I know that I can combine this motion into a single CCMoveTo however having them separate has some benefits (for example I can reverse the x or y motion independently).

Unfortunately moveUp is totally ignored. Any ideas why?


Solution

  • You can't run more than one CCMoveTo on the same node. Additional actions of the same type completely override any previous actions' results. The same is true for running two CCRotate*, CCScale* etc actions.

    If you want to be able to reverse direction, or in general be flexible about movement, then don't use CCMove* actions at all. They were not designed for gameplay purposes.

    Instead, use a scheduled update and manually update position based on velocity.