prime31 / TouchKit

Gestures and input handling made sane for Unity
906 stars 137 forks source link

TKSwipeRecognizer also needs gestureCompleteEvent #52

Open qria opened 8 years ago

qria commented 8 years ago

TKSwipeRecognizer also needs to fire gestureCompleteEvent when the finger is lifted if the swipe was recognized. This will be very useful in games where swipe is the main control, where you can implement long presses with this. Without this functionality, players have to swipe constantly to move. which is cumbersome to say the least.

I will try to implement it by myself and will make a pull request after finishing it.

qria commented 8 years ago

It was a pretty simple fix since the code is very readable but I have one problem.

I've changed TKSwipeRecognizer to set TKGestureRecognizerState.RecognizedAndStillRecognizing instead of TKGestureRecognizerState.Recognized to wait for TKSwipeRecognizer.touchesEnded(), and it works, but changing the state to TKGestureRecognizerState.Recognized after the press ends fires the gestureRecognizedEvent again. So I set it to TKGestureRecognizerState.FailedOrEnded to not trigger the event again. Is this okay?

prime31 commented 8 years ago

That sounds like it will work just fine. The FailedOrEnded state is there for just such occassions.