Reputation: 310
I would like to detect in my game the long press touch, but the problem is CCTargetedTouchDelegate
in Cocos2d 3.0
doesn't exist anymore to implement its delegates
. How can i do that?
Upvotes: 0
Views: 1320
Reputation: 144
http://www.cocos2d-x.org/attachments/1782/XTLayer.zip download this file. It has implemented different gestures
void xtTapGesture(CCPoint position) {}
virtual void xtDoubleTapGesture(CCPoint position) {}
virtual void xtLongTapGesture(CCPoint position) {}
virtual void xtSwipeGesture(XTTouchDirection direction, float distance, float speed) {}
you extend cclayer in your header file .. replace it with XTLayer and replace all touch events with xt instead of cc.
you can get more detail on http://www.cocos2d-x.org/forums/6/topics/23011
hope this helps.
Upvotes: 0
Reputation: 32066
(This is only valid for 2.1+)CCTargetedTouchDelegate
does still exist, but it has been renamed CCTouchOneByOneDelegate
.
It appears touch control has been moved to a CCResponder
. Instead of delegates, it appears to expect you to subclass it and override the touch methods:
– touchBegan:withEvent:
– touchMoved:withEvent:
– touchEnded:withEvent:
– touchCancelled:withEvent:
However for a long press, I'd probably still use the UILongPressGestureRecognizer
Upvotes: 2