首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >关于cocos2d-iphone的错误

关于cocos2d-iphone的错误
EN

Stack Overflow用户
提问于 2011-04-04 03:01:19
回答 1查看 214关注 0票数 0

我有三层??a,b和c。

的主要代码:

代码语言:javascript
复制
-(id) init
{
        // always call "super" init
        // Apple recommends to re-assign "self" with the "super" return value
        if( (self=[super init] )) {
                CCSprite *sp = [CCSprite spriteWithFile:@"bg.png"];
                sp.anchorPoint = CGPointZero;
                [self addChild:sp z:0 tag:1];

                [CCMenuItemFont setFontName: @"Georgia"];
                [CCMenuItemFont setFontSize:25];

                CCMenuItem *newGame = [CCMenuItemFont itemFromString:@"New Games" target:self selector:@selector(newGame:)];
                CCMenuItem *helpGame = [CCMenuItemFont itemFromString:@"Help" target:self selector:@selector(helpGame:)];

                CCMenu *menulist = [CCMenu menuWithItems:newGame, helpGame, nil];
                [menulist alignItemsVertically];

                [self addChild:menulist z:1 tag:2];

        }
        return self;
}

- (void) newGame:(id) sender
{
        CCScene *newscene = [CCScene node];
        [newscene addChild:[BScene node]];
        [[CCDirector sharedDirector] replaceScene:[CCTransitionShrinkGrow transitionWithDuration:1.2f scene:newscene]];

}

- (void) helpGame:(id) sender
{
        CCScene *newscene = [CCScene node];
        [newscene addChild:[CScene node]];
        [[CCDirector sharedDirector] replaceScene:[CCTransitionShrinkGrow transitionWithDuration:1.2f scene:newscene]];

}

B的主代码

代码语言:javascript
复制
-(id) init
{
        if( (self=[super init] )) {
                CCSprite *sp = [CCSprite spriteWithFile:@"bg.png"];
                sp.anchorPoint = CGPointZero;
                [self addChild:sp z:0 tag:1];

                CCBitmapFontAtlas *label = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Go back" fntFile:@"font01.fnt"];
                CCMenuItemLabel *back = [CCMenuItemLabel itemWithLabel:label target:self selector:@selector(backCallback:)];
                back.scale = 0.8;
               [self addChild:back z:1 tag:2];
        }
        return self;
}

- (void) dealloc
{
        [super dealloc];
}

-(void) backCallback: (id) sender
{
        CCScene *sc = [CCScene node];
        [sc addChild:[AScene node]];

        [[CCDirector sharedDirector] replaceScene:  [CCTransitionShrinkGrow transitionWithDuration:1.2f scene:sc]];        
}

当我单击进入b的startGame时,应用程序将退出,但如果我从b中删除以下代码,则函数运行正常,我可以进入b

代码语言:javascript
复制
CCBitmapFontAtlas *label = [CCBitmapFontAtlas bitmapFontAtlasWithString:@"Go back" fntFile:@"font01.fnt"];
            CCMenuItemLabel *back = [CCMenuItemLabel itemWithLabel:label target:self selector:@selector(backCallback:)];
            back.scale = 0.8;
           [self addChild:back z:1 tag:2];

那么,它有什么问题呢?非常感谢

EN

回答 1

Stack Overflow用户

发布于 2014-09-03 17:19:02

尝试使用CCLabelTTF,我一直在使用它,并且从来没有出现过问题。示例:

代码语言:javascript
复制
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello" fontName:@"Arial" fontSize:20];

希望这能有所帮助!

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5531750

复制
相关文章

相似问题

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