AniLongPressGestureRecognizer.h 1.24 KB
//
//  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 */