Set Background to CCScene

266 Views Asked by At

How could I set a background to the CCScene? What I want is when I zoom out or in my CCLayer the background size stay the same. Thanks in advance.

1

There are 1 best solutions below

0
On

I share the code

+(CCScene *) scene

{ // 'scene' is an autorelease object. CCScene *scene = [CCScene node];

// 'layer' is an autorelease object.
ActionLayer *layer = [ActionLayer node];

// add layer as a child to scene
[scene addChild: layer];

CCSprite *background =[CCSprite spriteWithFile:@"sky.jpg"];
CCLayer *backgroundLayer = [CCLayer node];
[backgroundLayer addChild:background];

[scene addChild:layer.backgroundLayer z:-1];

// return the scene
return scene;

}