我有一个 CCLayer,用作暂停菜单。它占据了整个屏幕,但目前允许触摸通过它。
我想防止触摸通过它,但我遇到了一些困难。这是我所拥有的:
-(id)init{
if(self = [super init]){
CGSize s = [[CCDirector sharedDirector] winSize];
self = [CCLayerColor layerWithColor: ccc4(11, 153, 223, 255) width: s.width height: s.height];
self.position = CGPointZero;
self.isTouchEnabled = YES;
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
}
return self;
}
不过,碰触层会导致崩溃,而且似乎也能通过它。
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Layer#ccTouchBegan override me'
防止触摸通过此 cclayer 的最简单方法是什么?谢谢