开发者

Scrolling Scene in cocos2d

开发者 https://www.devze.com 2023-03-08 04:28 出处:网络
I have a sprite which moves across the screen.so i want to switch between the scenes.how can i do that.i am not interested开发者_JS百科 in using Tile Map.I want just like angry birds scene scrolling.

I have a sprite which moves across the screen.so i want to switch between the scenes.how can i do that.i am not interested开发者_JS百科 in using Tile Map.I want just like angry birds scene scrolling.

Any Idea,

Thanks


If i understand what your asking you could just add everything to a cclayer and have everything as a child of it and move the full layer left or right to scroll


As glogic says, create a CCLayer and then add a CCSprite to it with an image much larger than the screen size.

Now in your touch handling code, do something like this...

OnTouchBegin - store position of the touch

OnTouchMoved - calculate distance from stored position where touch started and move the whole layer by that much.

OnTouchEnd - If your sprite has move too far and you have gone off the edge of the sprite, slide it back to the edge

0

精彩评论

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