Cocos2D - Automatically control the movement of sprites with speed

I was wondering how I could immediately make my CCSprite *van sprite automatically from the very beginning with a controlled speed, for example int *speed = 1, 2, 3+ . I looked around, but everything I found did not fit my needs. Is there a simple solution to this problem?

+4
source share
1 answer

You should use the CCSpeed ​​action:

 CCSpeed* speed= [CCSpeed actionWithAction: yourMoveAction speed: 1.0f]; // yourMoveAction is an action like CCMoveTo for example [sprite runAction: speed]; 

Then you can change the speed while the sprite moves with setSpeed:

 [speed setSpeed: 2.0f]; 
+3
source

All Articles