我有三层??a,b和c。
的主要代码:
-(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的主代码
-(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
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];那么,它有什么问题呢?非常感谢
发布于 2014-09-03 17:19:02
尝试使用CCLabelTTF,我一直在使用它,并且从来没有出现过问题。示例:
CCLabelTTF *label = [CCLabelTTF labelWithString:@"Hello" fontName:@"Arial" fontSize:20];希望这能有所帮助!
https://stackoverflow.com/questions/5531750
复制相似问题