AniLongPressGestureRecognizer.h
1.24 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
//
//  AniLongPressGestureRecognizer.h
//  SteveMaggieCpp
//
//  Created by Katarzyna Kalinowska-Górska on 19.05.2017.
//
//
#ifndef AniLongPressGestureRecognizer_h
#define AniLongPressGestureRecognizer_h
#include "AniGestureRecognizer.h"
class AniLongPressGestureRecognizer : public AniGestureRecognizer
{
    public:
        AniLongPressGestureRecognizer(float waitTime = 1);
        virtual ~AniLongPressGestureRecognizer();
    
        virtual void setOnLongPressDetectedCallback(std::function<void(cocos2d::Point touchLocation)> callback);
    
    protected:
        std::function<void(cocos2d::Point touchLocation)> _onLongPressDetected;
        std::function<void(float )> _callback;
    
        // helper constant
        const float MAX_DELTA = 10;
        
        // helper temp vars
    
        int _waitTime;
        long long _startTime;
        cocos2d::Point _startLocation;
        bool _callbackScheduled;
    
        //////
        virtual bool onTouchBegan(cocos2d::Touch* touch, cocos2d::Event* event) override;
        virtual void onTouchMoved(cocos2d::Touch* touch, cocos2d::Event* event) override;
        virtual void onTouchEnded(cocos2d::Touch* touch, cocos2d::Event* event) override;
};
#endif /* AniLongPressGestureRecognizer_h */
