1

Can any one tell me how to move a CClayer. Like DoodleJump when object will move upward the background will also move upward.Plz Explain me with some sample code.

Ivan Mir
  • 1,209
  • 1
  • 12
  • 32
russell
  • 3,668
  • 9
  • 43
  • 56
  • possible duplicate of [How to move background in cocos 2d](http://stackoverflow.com/questions/4395959/how-to-move-background-in-cocos-2d) – Andy Dent Mar 07 '12 at 06:18

5 Answers5

4

Use CCFollow actions.

Make your background sprite height some 1000 px.

[self runAction:[CCFollow actionWithTarget:(u r hero) worldBoundary:CGRectMake(0,0,480,1050)]];
Rob
  • 415,655
  • 72
  • 787
  • 1,044
Srinivas
  • 1,059
  • 1
  • 11
  • 26
4

This tutorial will teach you how to make a game very similar to doodle jump: Tutorial Part 1

Hope it helps :)

P.S. Check out this guys' channel he has the solution to your background problem.

JJgendarme
  • 1,411
  • 2
  • 16
  • 30
1

Look at the tile maps code from the cocos2d sample code that is included with cocos2d.

slycrel
  • 4,275
  • 2
  • 30
  • 30
0

The most basic answer to the question in the title is:

a CCLayer is a CCNode and can be moved by repositioning it:

myLayer.position = ccp(x,y);
-1

use ccaction like ccmoveby or ccmoveto , etc.,

Sri
  • 827
  • 8
  • 34