【问题标题】:Coco2dx - Changing To Background ImageCocos2d - 切换到背景图片
【发布时间】:2015-08-30 12:21:50
【问题描述】:

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

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

【问题讨论】:

    标签: ios iphone xcode xcode6 ios-simulator


    【解决方案1】:

    创建并添加一个CCSprite

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-29
      • 1970-01-01
      相关资源
      最近更新 更多