【发布时间】:2014-07-20 20:24:28
【问题描述】:
我正在尝试在 Cocos2d 3.1 中做一些相当简单的事情。我正在接收 CCSprite 子类上的触摸事件,并且我试图在使用简单的 containsTouchLocation 辅助方法将触摸从精灵滑出时停止接收触摸事件。
但是,如果我在 touchMoved: 方法中执行 self.userInteractionEnabled = NO;,它仍然会调用 touchMoved!
这是我完整的 touchMoved: 方法:
- (void)touchMoved:(UITouch *)touch withEvent:(UIEvent *)event {
self.userInteractionEnabled = NO;
int color = ([self containsTouchLocation:touch] ? 128 : 255);
self.color = [CCColor colorWithCcColor3b:ccc3(color, color, color)];
}
为什么即使我在touchMoved方法中明明想关闭触摸事件,它仍然在调用它?
【问题讨论】:
-
可能只影响当前的触摸,即禁用交互只对以后的触摸生效,而当前的触摸允许接收移动和结束的事件?
-
@LearnCocos2D 是的,它似乎停止了所有未来的接触。我将如何停止当前的触摸?
-
根据我的研究,没有办法做到这一点。因此,与此同时,我只使用了 BOOL 并且不会在需要时调用代码。您是否知道是否有一种方法可以为仍在进行的触摸停止触摸事件?
标签: ios cocos2d-iphone touches user-interaction