我创建了一个新层,向它们添加了三个菜单项,并且我对它们中的每一个都有方法,它们登录到控制台并切换视图,但没有任何反应。为什么会这样?
- (id) init
{
if (self = [super init])
{
[self setIsTouchEnabled:YES];
CCSprite *background = [CCSprite spriteWithFile:@"bg.png"];
[background setPosition:CGPointMake(size.width / 2, size.height / 2)];
[self addChild:background z: 0];
CCMenuItemFont *menu1 = [CCMenuItemFont itemFromString:@"New game" target:self selector:@selector(startNewGame)];
[menu1 setPosition:CGPointMake(size.width / 2, 330)];
CCMenuItemFont *menu2 = [CCMenuItemFont itemFromString:@"Options" target:self selector:@selector(options)];
[menu2 setPosition:CGPointMake(size.width / 2, 250)];
CCMenuItemFont *menu3 = [CCMenuItemFont itemFromString:@"Credits" target:self selector:@selector(credits)];
[menu3 setPosition:CGPointMake(size.width / 2, 170)];
[self addChild:menu1];
[self addChild:menu2];
[self addChild:menu3];
}
return self;
}
- (void) credits
{
NSLog(@"In credits");
}
// same methods for new game and options. It never gets called.