Coco2dx - Changing To Background Image

51 Views Asked by At

I need someone's help. Actually I have no idea what to replace to get a custom background image. I'm just can't do it anymore.

    -(id) init
{
    // always call "super" init
    // Apple recommends to re-assign "self" with the "super's" return value
    if( (self=[super initWithColor:ccc4(219,31,94, 999)]) ) {
        ws=[[CCDirector sharedDirector]winSize];
        NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"game" ofType:@"wav"];
        NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
        AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
        player.numberOfLoops=-1;
        [player play];
1

There are 1 best solutions below

0
On BEST ANSWER

Create and add a CCSprite:

CCSprite *bg = [CCSprite spriteWithFile:@"bg.png"];
bg.tag = 1;
bg.anchorPoint = CGPointMake(0, 0);
[self addChild:bg];