AniSimpleFastSwipeGestureRecognizer.h
1.18 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
//
// AniFastSwipeGestureRecognizer.h
// SteveMaggieCpp
//
// Created by Katarzyna Kalinowska-Górska on 19.05.2017.
//
//
#ifndef AniFastSwipeGestureRecognizer_h
#define AniFastSwipeGestureRecognizer_h
#include "AniGestureRecognizer.h"
class AniSimpleFastSwipeGestureRecognizer : public AniGestureRecognizer
{
public:
AniSimpleFastSwipeGestureRecognizer();
virtual ~AniSimpleFastSwipeGestureRecognizer();
virtual void setOnFastSwipeDetectedCallback(std::function<void(std::string direction, cocos2d::Point startLocation, cocos2d::Point endLocation, float velocity)> callback);
protected:
std::function<void(std::string direction, cocos2d::Point startLocation, cocos2d::Point endLocation, float velocity)> _onFastSwipeDetected;
// helper constant
const float MIN_SWIPE_VELOCITY = 900;
// helper temp vars
double _startTime;
cocos2d::Point _startLocation;
virtual bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event) override;
virtual void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event) override;
};
#endif /* AniFastSwipeGestureRecognizer_h */