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

In my cocos2d app I was wondering how to make a CCSprite move on the screen but have the screen focused on the CCSprite, so when the sprite moves the view moves with the CCSprite. Is there a tutorial to do this?


share|improve this question

There's a CCFollow action in cocos2d for this purpose. Usage is simple:

[myLayer runAction: [CCFollow actionWithTarget: heroSprite]];

For more information, have a look at the API docs.

share|improve this answer

For making such games you need to create some layers and then move the layers. Just like in a 2D side scrolling game the background layer moves(or changes) and only the y coordinate of the character is changed so that the character appears to be moving.

For such game you can refer to this post ---

and to find additional codes for the same you can check out the code snippet and the end of this page.

share|improve this answer

If, for some reason, you wanted to manually make a camera system, the way to do it would be to set a camera x and y based on the position of the sprite you're trying to follow, and then draw everything at its normal position minus the camera x and y values.

share|improve this answer

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.