所以我自己在我的游戏中一直在使用 CCPanZoomController 并且遇到了和你类似的问题,但是有很多不同的方面,比如当他们触摸一个精灵时,我不想让背景随之移动,或者我想要当背景缩放时,精灵不会移动。所以我所做的是为我不想做出反应的层创建方法来“关闭”触摸,并在另一层中的操作完成后重新启用它们。
我在每一层中创建了以下方法来禁用它或启用它以用于我从不同的触摸事件调用的触摸。
// Public Method: Allows for disabling touch for this layer and re-enabling it
-(void)enableTouches:(BOOL)enable
{
// Check if the bool value is to enable or disable touches
if (enable) {
// Call for the removal of all touch locations in array in the CCLayerPanZoom instance
[_panZoomLayer removeTouchesFromArray];
// Call the touch dispatcher and add the CCLayerPanZoom back as a delegate for touches
[[CCTouchDispatcher sharedDispatcher] addStandardDelegate:_panZoomLayer priority:0];
CCLOG(@"PanZoomWrapperLayer:enableTouches - LayerPanZoom touches enabled");
} else {
// Call the touch dispatcher to remove the CCLayerPanZoom as a delegate to disable touches
[[CCTouchDispatcher sharedDispatcher] removeDelegate:_panZoomLayer];
CCLOG(@"PanZoomWrapperLayer:enableTouches - LayerPanZoom touches disabled");
}
}