AniGestureRecognizer.h
3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// 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<cocos2d::EventListener::Type> 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<cocos2d::EventListener::Type> _handledEvents;
cocos2d::Node* _view;
bool _enabled;
std::vector<TouchData> _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<cocos2d::Touch*>& touches, cocos2d::Event* event);
virtual void onTouchesMoved(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
virtual void onTouchesEnded(const std::vector<cocos2d::Touch*>& touches, cocos2d::Event* event);
virtual void saveTouches(std::vector<TouchData>& rememberedTouches, const std::vector<cocos2d::Touch*>& touches);
virtual void updateTouches(std::vector<TouchData>& rememberedTouches, const std::vector<cocos2d::Touch*>& touches);
virtual void filterTouches(std::vector<TouchData>& rememberedTouches, const std::vector<cocos2d::Touch*>& touches);
virtual cocos2d::Touch* findTouchWithID(const std::vector<cocos2d::Touch*>& touches, int touchId);
};
#endif /* AniGestureRecognizer_h */