I hope someone knows how to do the following with cocos2d:

I want a sprite to move but not in a single line by using

[cocosGuy runAction: [CCMoveTo actionWithDuration:1 position:location]];  

What I want is the sprite to do some kind of movements that I preestablish. For example in some point i want the sprirte to move for instance up and then down but in a curve. Do I have to do this with flash like this documents says?


Does animation in this page means moving sprites or what?



The document you linked to describes approaches to animating sprites. This (usually) doesn't involve the movement of the sprite, but rather an image-sequence that is played in place. Eg. a walk-cycle animation (which will give the impression of a walking character if the sprite is additionally moved).

You're on the right track with your approach. Instead of running a single action, you should run a sequence of actions instead. This could be a movement upwards, followed by a CCBezierTo or CCBezierBy action, which allows movement along a Bezier curve.

Using the CCSequence allows for some pretty complex animations. You can even add special actions like CCCallFunc or similar to execute code at certain points in your sequence.

  • \$\begingroup\$ Oh, so for example I can first do a move, then enter a function and depending on the sprite's position do one or another move right? Is that possible? \$\endgroup\$
    – marcg11
    Nov 24 '11 at 22:40
  • \$\begingroup\$ That's possible. You can run a sequence with: Move, CallFunction. And then in that function that is being called you could run another action or sequence. There are lots of possibilities with this system. \$\endgroup\$
    – bummzack
    Nov 24 '11 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.