我应该如何改变它以使用CCParallaxNode?

时间:2013-08-17 19:53:20

标签: objective-c cocos2d-iphone background-image side-scroller

您好我是cocos2d和Objective c的初学者。我正在制作一个cocos2d侧卷轴。如何使这段代码连续?

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

1 个答案:

答案 0 :(得分:0)

查看一系列精彩的教程on Ray Wenderlich site

您要问的部分包含在添加视差滚动段落中。