Coco2dx - 更改为背景图像

时间:2015-06-15 05:20:33

标签: ios iphone xcode xcode6 ios-simulator

我需要别人的帮助。实际上我不知道要替换什么来获得自定义背景图像。我不能再这样做了。

    -(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 个答案:

答案 0 :(得分:1)

创建并添加CCSprite

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