屏蔽方法:
进入新的CCLayer时:
[[CCDirector sharedDirector].touchDispatcher addTargetedDelegate:self priority:kCCMenuHandlerPriority swallowsTouches:YES];
离开此CCLayer时调用
[[CCDirector sharedDirector].touchDispatcher removeDelegate:self];
重写方法
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event;
解释:
由于CCMenu 按钮接受按键的优先级为-128(值越小优先级越高),所有不论处在那一层都会接收到点击
[[CCDirector sharedDirector].touchDispatcher addTargetedDelegate:self priority:kCCMenuHandlerPriority swallowsTouches:YES];
priority: 优先级 kCCMenuHandlerPriority(-128)
swallowsToucher: 是否吃掉按钮不叫其他层再接收了 如果为NO其他层还是一样会接收到Touch数据
注意离开此CCLayer时一定要调用
[[CCDirector sharedDirector].touchDispatcher removeDelegate:self];
否则下面层将不再接收按键
posted on 2012-10-20 12:07
CrackRen 阅读(682)
评论(0) 编辑 收藏 所属分类:
iPhone