Pregunta

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));
}
¿Fue útil?

Solución

Check out great series of tutorials on Ray Wenderlich site

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top