Problem with cocos2D for iPhone and touch detection

后端 未结 7 993
后悔当初
后悔当初 2021-02-01 09:03

I just don\'t get it. I use cocos2d for development of a small game on the iPhone/Pod. The framework is just great, but I fail at touch detection. I read that you just need to o

7条回答
  •  隐瞒了意图╮
    2021-02-01 09:33

    In order to detect touches, you need to subclass from UIResponder (which UIView does as well) . I am not familiar with cocos2D, but a quick look at the documentation reveals that CocosNode does not derive from UIResponder.

    Upon further investigation, it looks like Cocos folks created a Layer class that derives from CocosNode. And that class implements the touch event handlers. But those are prefixed by cc.

    See http://code.google.com/p/cocos2d-iphone/source/browse/trunk/cocos2d/Layer.h

    Also see menu.m code and the below blog post article for more info on this:

    http://blog.sapusmedia.com/2008/12/cocos2d-propagating-touch-events.html

提交回复
热议问题