AniSimpleFastSwipeGestureRecognizer.h 1.18 KB
//
//  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 */