iOS Dev (71) ccTouchBegan 无响应的可能原因
- 博客:http://blog.youkuaiyun.com/prevention
- 作者:大锐哥
- 摘自:
Learn iPhone and iPad cocos2d Game Development
-
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
...
}
在自定义的 Layer 类中增加如下方法:
- (void)registerWithTouchDispatcher
{
[[CCTouchDispatcher sharedDispatcher]
addTargetedDelegate:self priority:0 swallowsTouches:YES];
}
-
本文介绍了当ccTouchBegan方法在Cocos2d游戏中无响应时的可能原因及解决方案。通过在自定义Layer类中注册触摸分发器,确保触摸事件能够被正确处理。
1万+

被折叠的 条评论
为什么被折叠?



