Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
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? – marcg11 Nov 24 '11 at 22:40
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. – bummzack Nov 24 '11 at 22:48
Great! Thanks!!! – marcg11 Nov 24 '11 at 23:20

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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