russell
russell

Reputation: 3766

How to move CCLayer in cocos2d

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.

Upvotes: 1

Views: 3048

Answers (5)

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);

Upvotes: 0

Srinivas
Srinivas

Reputation: 1059

Use CCFollow actions.

Make your background sprite height some 1000 px.

[self runAction:[CCFollow actionWithTarget:(u r hero) worldBoundary:CGRectMake(0,0,480,1050)]];

Upvotes: 4

JJgendarme
JJgendarme

Reputation: 1401

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.

Upvotes: 4

Srini
Srini

Reputation: 827

use ccaction like ccmoveby or ccmoveto , etc.,

Upvotes: -1

slycrel
slycrel

Reputation: 4285

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

Upvotes: 1

Related Questions