문제

I've seen many tutorials but not similar with what I'm trying to build...

Creating a parallax view with 3 sprites (background, layer 1, layer 2)

//Adding a like this        
CCSprite *sprite = [CCSprite spriteWithFile:@"spriteImage.png"];
sprite.anchorPoint = CGPointZero;
[self addChild:sprite z:-1]; //and chaining the z's value for each sprite

How I implement the scroll of the screen and the sprites would move with different speed?

Any suggestions would be great!

P.S. Want to use touch events (when swiping to scroll)

도움이 되었습니까?

해결책 2

Found it, you can add the sprite directly to a parallaxNode or add the sprite to a CCLayer and the CCLayer to parallaxNode; something like:

[parallaxNode addChild:sprite z:0 parallaxRatio:CGPointMake(0,0) positionOffset:ccp(x,y)];

다른 팁

If you're using particularly large background images, you'll probably want to take a look at http://www.raywenderlich.com/1163/how-to-make-a-tile-based-game-with-cocos2d. Included in that tutorial is a guide to making images move when you scroll around.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top