2015-06-15 84 views
0

我需要某人的帮助。其实我不知道要取代自定义背景图像。我不能再做了。Coco2dx - 更改为背景图片

-(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

创建并添加CCSprite

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