Saturday, 17 August 2013

how should I change this to use CCParallaxNode?

how should I change this to use CCParallaxNode?

Hello I am a beginner to cocos2d and objective c. I am making a cocos2d
side scroller. I am using CCActions to make my background move. I want my
app to be universal. Right now I am making my app for the iPad, but I want
to make it compatible with all iPhone, iPod Touch, and iPad versions. I am
now learning that CCParallaxNode might make it easier to make the app
universal. Here is my code that I am using right now.
treeBackground = [CCSprite spriteWithFile:@"background.png"
rect:CGRectMake(0, 0, screenWidth * 2, screenHeight * 1.25)];
treeBackground.opacity = treeBackground.opacity - 75;
ccTexParams params = {GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT};
[treeBackground.texture setTexParameters:&params];
treeBackground.position = ccp(screenWidth, screenHeight/2);
[self addChild:treeBackground z:-5];
CCMoveBy* treeBackgroundMove = [CCMoveBy actionWithDuration:20.0
position:ccp(screenWidth * -1, 0)];
CCPlace* treeBackgroundPlace = [CCPlace
actionWithPosition:ccp(screenWidth, screenHeight/2)];
CCSequence* treeBackgroundSequence = [CCSequence
actions:treeBackgroundMove, treeBackgroundPlace, nil];
CCRepeatForever* treeBackgroundRepeat = [CCRepeatForever
actionWithAction:treeBackgroundSequence];
[treeBackground runAction:treeBackgroundRepeat];
How can I change this to use CCParallaxNode??

No comments:

Post a Comment