fljot / GestouchExamples

Examples for Gestouch library.
https://github.com/fljot/Gestouch
MIT License
58 stars 13 forks source link

Swipe gesture GESTURE_ENDED #9

Closed bilalsavas closed 9 years ago

bilalsavas commented 9 years ago

Hi,

I'm trying to start a timer when swipe gesture starts, I can do this with GESTURE_RECOGNIZED event, but I also need to stop timer when gesture ends (no fingers on screen),

It seems that GESTURE_ENDED function is not working with swipe gesture, because of that I put an if statement in timer "if (swipeGesture.numTouches==0) timer.stop(); " but numtouches always return 0 even if there are more than one finger on screen, so timer immediately stops.

To sum up, what Im trying to do is "Do this while making swipe gesture"

Note : GESTURE_CHANGED is also not working with swipe so I came up with timer idea.

all the events I mentioned work with transformGesture without a problem

is there a workaround for this ? or should it work normally ?

my swipe definition ;

leftSwipe = new SwipeGesture(stage); leftSwipe.direction = SwipeGestureDirection.LEFT; leftSwipe.numTouchesRequired = 2; leftSwipe.addEventListener(org.gestouch.events.GestureEvent.GESTURE_RECOGNIZED, onLeftSwipe); leftSwipe.addEventListener(org.gestouch.events.GestureEvent.GESTURE_ENDED, stopTTtimer)

Thanks

bilalsavas commented 9 years ago

Sorry for opening this issue to possibly wrong repository,

I solved the issue with using Pan gesture, in pan both GESTURE_BEGAN, GESTURE_CHANGED events are working. and it also has direction & numtouchesrequired properties like swipe.

fljot commented 9 years ago

Good that you found some different approach.

But it seems like it was very unclear to you at first, and I'm not sure why... why did you think Swipe gesture would dispatch those events?

bilalsavas commented 9 years ago

I havent used any touch events in no platform whatsoever. So I didn't know which gesture is called what. And the images/icons of swipe gesture in google images were looked like what I wanted, so I started from there, and the other main reason I used swipe is it had direction LEFT-RIGHT-UP-DOWN properties, because I needed those. (Pan only had VERTICAL-HORIZONTAL)

Think of a 3d model viewing on screen, to rotate it you slide your finger horizontally to left or right (Im not sure if its what pan stands for :D), I needed direction, and as long as I'm continuing my gesture it should rotate, therefore I needed both direction, and GESTURE_CHANGED event. Swipe had 4-direction, didnt had necessary events, pan had events and 2-direction.

So, I ended up modifying PanGesture, added directions(LEFT-RIGHT-UP-DOWN) to it, now its working fine except rarely GESTURE_ENDED doesnt fire.

But I understand that now you asked, swipe is one time triggering event in general.

I don't know if this was the right way of doing this or not, if there is a better or built in way please let me know, but for now its working quite nice.

Btw, thank you for the library, its really great.