I want to add a background to a side scroll game that moves at a different rate to the main game layer. What would be the best way to do this? I may want 2 background layers, each scrolling slower than the other to give a sense of depth when the player moves.
Also, what is the best way to create a layer, and have direct control over it? At the moment a layer is created but I cant access it in other parts of the code. This is how its done by default which is the way I am using:
+(CCScene *) scene
{
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layer' is an autorelease object.
HelloWorldLayer *layer = [HelloWorldLayer node];
// add layer as a child to scene
[scene addChild: layer];
// return the scene
return scene;
}
Thanks
CCParallaxNode is good for you.
Refer ParallaxTest in Cocos2D sample.