开发者

How to move CCLayer in cocos2d

Can any one tell me how to move a CClayer. Li开发者_JS百科ke DoodleJump when object will move upward the background will also move upward.Plz Explain me with some sample code.


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.


Use CCFollow actions.

Make your background sprite height some 1000 px.

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


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


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


use ccaction like ccmoveby or ccmoveto , etc.,

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜