Question

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?

Was it helpful?

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.

OTHER TIPS

Use the CCSpawn action, it allows you to run two actions at the same time http://www.cocos2d-iphone.org/api-ref/2.0.0/interface_c_c_spawn.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top