我有一個CCLayer,我用它作爲暫停菜單。它佔據了整個屏幕,但目前允許觸摸通過它。防止觸摸通過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?謝謝
我認爲sharedDispatcher已折舊,我切換到此:[[CCDirector sharedDirector] touchDispatcher] – Muskie