首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cocos2d 2.0黑屏ccscene

Cocos2d 2.0黑屏ccscene
EN

Stack Overflow用户
提问于 2012-11-20 08:07:10
回答 1查看 486关注 0票数 1

我在使用Cocos2d 2.0版本时遇到了很大的麻烦

问题:在启动应用程序后,我的gamescene不会出现在屏幕上,无论我做什么,都会出现地狱般的黑屏。

下面是我的代码的延伸部分。

如果你们能帮助我,我将不胜感激!

代码语言:javascript
复制
//AppDelegate from cocos2d basic template, I change this line
[director_ pushScene:[GameScene node]];

//my GameScene class implementation
- (id)init
{
   if(self != nil)
    {
        BackgroundLayer *backgroundLayer = [BackgroundLayer node];
        [self addChild:backgroundLayer z:0];
    }

    return self;
}

//then, my BackgroundLayer class implementation
- (id)init
{
    if(self != nil)
    {
        CCSprite *backgroundImage = [CCSprite spriteWithFile:@"backgroundiPhone.png"];

        CGSize screenSize = [[CCDirector sharedDirector] winSize];
        [backgroundImage setPosition:CGPointMake(screenSize.width / 2, screenSize.height / 2)];
        //yea the image is in the project, maybe if I add some color at the sprite to be sure?

        [self addChild:backgroundImage z:0 tag:0];
    }

    return self;
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-20 12:31:56

为什么不在init方法中调用parent的init呢?将这一行添加到init方法的开头。

代码语言:javascript
复制
self = [super init];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13464635

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档