我不知道出了什么问题,也许是因为我使用了更多层?
我认为我的另一层(滑动菜单网格子类正在窃取触摸...) // // BGLayer.m // MainProject // // 由 NSSL1 于 2012 年 8 月 30 日创建。// 版权所有 (c) 2012 MyCompanyName。版权所有。//
#import "BGLayer.h"
#import "GameManager.h"
#import "MainMenuLayer.h"
@interface BGLayer()
-(void)displayBGMenu;
@end
@implementation BGLayer
-(void)backtomenu:(CCMenuItem*)itemPassedIn{
CCLOG(@"why I can't reach here?");
[[GameManager sharedGameManager] runSceneWithID:kMainMenuScene];}
-(id)init {
self = [super init];
if (self != nil) {
self.isTouchEnabled=YES;
[self displayBGMenu];
}
return self;
}
-(void)displayBGMenu{
NSString* backLabelstring = [NSString stringWithFormat:@"Back to Menu"];
CGSize screenSize = [CCDirector sharedDirector].winSize;
//Shadow
CCLabelTTF *backLabel = [CCLabelTTF labelWithString:backLabelstring fontName:@"Marker Felt" fontSize:32];
backLabel.position=CGPointMake(screenSize.height*0.5f, screenSize.width*0.1f);
backLabel.color = ccBLUE;
CCMenuItem* backbtnitem=[CCMenuItemLabel itemWithLabel:backLabel target: self
selector:@selector(backtomenu:)];
[backbtnitem setTag:21];
menu = [CCMenu menuWithItems:backbtnitem ,nil];
menu.position = CGPointMake((screenSize.width / 2), screenSize.height*0.1f);
menu.tag = 200;
[self addChild:menu z:20 tag:200];
}
@end