【发布时间】:2011-10-03 19:00:08
【问题描述】:
所以我创建了一个暂停菜单,
- (void) reset {
CCSprite * backg = [CCSprite spriteWithFile:@"noise.png"];
backg.position = ccp(480/2, 320/2);
[pauseMenu addChild:backg];
CCLabelBMFont *restartLabel = [CCLabelBMFont labelWithString:@"Restart" fntFile:@"good_dog_plain_32.fnt"];
restartLabel.color = ccc3(68,136,168);
CCMenuItemLabel *restartItem = [CCMenuItemLabel itemWithLabel:restartLabel target:self selector:@selector(restartMenu)];
restartItem.position = ccp(0, 40);
CCLabelBMFont *mainMenuLabel = [CCLabelBMFont labelWithString:@"Main Menu" fntFile:@"good_dog_plain_32.fnt"];
mainMenuLabel.color = ccc3(68,136,168);
CCMenuItemLabel *mainMenuItem = [CCMenuItemLabel itemWithLabel:mainMenuLabel target:self selector:@selector(exitMenu)];
mainMenuItem.position = ccp(0, -40);
CCLabelBMFont *resumeLabel = [CCLabelBMFont labelWithString:@"Resume" fntFile:@"good_dog_plain_32.fnt"];
resumeLabel.color = ccc3(68,136,168);
CCMenuItemLabel *resumeItem = [CCMenuItemLabel itemWithLabel:resumeLabel target:self selector:@selector(resumeMenu)];
CCMenu *menu = [CCMenu menuWithItems:resumeItem,restartItem,mainMenuItem, nil];
menu.position = ccp(480/2,320/2);
[pauseMenu addChild:menu z:1];
[self.hero sleep];
[self addChild:pauseMenu];
}
这个菜单是在我的游戏场景中创建的,所以每当用户按下暂停按钮时,它就会出现,现在我有另一个场景叫做mainMenu,你可以从暂停菜单转到mainMenu,我使用了这个代码:
- (void) exitMenu {
[[CCDirector sharedDirector] replaceScene:[mainMenu scene]];
}
因此,一旦您按下此按钮,它就会起作用并返回主菜单,但是当我按下 mainMenu 中的“播放”按钮并进入游戏并按下暂停按钮时,我收到此错误:@ 987654326@ ...如果我从暂停菜单重新启动游戏场景,则不会发生这种情况,只有在加载游戏后从主菜单进入游戏时才会发生这种情况。
【问题讨论】:
标签: iphone objective-c ios cocoa cocos2d-iphone