문제

Hello I am a beginner to cocos2d and objective c. I am making a cocos2d side scroller. How can I make this code be continuous??

 backgroundNode = [CCParallaxNode node];
    [self addChild:backgroundNode z:-5];
    treeBackground = [CCSprite spriteWithFile:@"thechangedbackgroundcopy.png"];
    CGPoint backgroundSpeed = ccp(0.5, 0.5);
    [backgroundNode addChild:treeBackground z:-5 parallaxRatio:backgroundSpeed positionOffset:ccp(screenWidth/2, screenHeight/2 - 50)];

    [self scheduleUpdate];



-(void)update:(ccTime)delta{
CGPoint backgroundScrollVelocity = ccp(-150, 0);
backgroundNode.position = ccpAdd(backgroundNode.position, ccpMult(backgroundScrollVelocity, delta));
}
도움이 되었습니까?

해결책

Check out great series of tutorials on Ray Wenderlich site

The part you ask about is covered in the Adding Parallax Scrolling paragraph.

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