// // AniGestureRecognizer.h // SteveMaggieCpp // // Created by Katarzyna Kalinowska-Górska on 19.05.2017. // // #ifndef AniGestureRecognizer_h #define AniGestureRecognizer_h #include "cocos2d.h" class AniGestureRecognizer : public cocos2d::Ref { public: typedef enum AniGestureRecognizerDirection { NONE, UP, DOWN, LEFT, RIGHT }; static AniGestureRecognizerDirection mapXToDirection(float x); static AniGestureRecognizerDirection mapYToDirection(float y); AniGestureRecognizer(std::vector handledEvents); virtual ~AniGestureRecognizer(); virtual void install(cocos2d::Node* view); virtual void uninstall(); virtual void setEnabled(bool enabled){_enabled = enabled;} virtual bool isEnabled(){return _enabled;} virtual void changeTouchListenerPriorityToFixed(int newPriority); virtual void changeTouchListenerPriorityToSceneGraphPriority(); virtual void setSwallowsTouches(bool swallowsTouches); typedef struct TouchData { int touchId; cocos2d::Point currentTouchLocation; cocos2d::Point previousTouchLocation; cocos2d::Point initialTouchLocation; TouchData(){ touchId = -1; }; TouchData(int pTouchID, cocos2d::Point pCurrentTouchLocation, cocos2d::Point pPreviousTouchLocation, cocos2d::Point pInitialTouchLocation){ touchId = pTouchID; currentTouchLocation = pCurrentTouchLocation; previousTouchLocation = pPreviousTouchLocation; initialTouchLocation = pInitialTouchLocation; }; } TouchData; protected: std::vector _handledEvents; cocos2d::Node* _view; bool _enabled; std::vector _rememberedTouches; cocos2d::EventListener* _eventListener; virtual bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event); virtual void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event); virtual void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event); virtual bool onTouchesBegan(const std::vector& touches, cocos2d::Event* event); virtual void onTouchesMoved(const std::vector& touches, cocos2d::Event* event); virtual void onTouchesEnded(const std::vector& touches, cocos2d::Event* event); virtual void saveTouches(std::vector& rememberedTouches, const std::vector& touches); virtual void updateTouches(std::vector& rememberedTouches, const std::vector& touches); virtual void filterTouches(std::vector& rememberedTouches, const std::vector& touches); virtual cocos2d::Touch* findTouchWithID(const std::vector& touches, int touchId); }; #endif /* AniGestureRecognizer_h */