Detecting when a finger slides off a display object

As far as I could tell, there are 4 phases to a touch event. In a game I’m working on, I need to detect when a finger slides OFF a display object. What would be the best approach to solving this?

Thanks! [import]uid: 44037 topic_id: 8987 reply_id: 308987[/import]

I have this question as well. This seems like such a common use case I must be missing something. Can someone point me in the right direction?

-Andy [import]uid: 52627 topic_id: 8987 reply_id: 36019[/import]

In the code for Mutant ABCs I created a routine for the Next and Previous buttons that would highlight when you touched – and if you dragged your finger off and then back on it would unhighlight/highlight as needed.

Basically, look for the “moved” event.phase and see if the event.x and event.y coordinates are inside the target object. If not, you know the finger has slid off the object.

Jay [import]uid: 9440 topic_id: 8987 reply_id: 36021[/import]

So to do this you have to have a global listener that checks all buttons in the game, right? [import]uid: 44037 topic_id: 8987 reply_id: 36022[/import]

I just have a listener for each button that can be touched – it’s actually the same listener that handles the highlight/unhighlight action for all buttons. When each button is released the listener checks to see which button it was and runs the appropriate code.

I’m actually in the middle of writing up an article about this for my GameDevNation.com site. If you’re a member (blatant plug) you’ll see if online probably some time tomorrow.

Jay
[import]uid: 9440 topic_id: 8987 reply_id: 36025[/import]

Thanks.
I’d love to see the code. I used a global listener, since if I attach the listener to every button, then the move event doesn’t fire if the finger is no longer on the button [import]uid: 44037 topic_id: 8987 reply_id: 36026[/import]

Here’s a link to a video that shows what I do:

http://instantvideowebpages.com/play/?m=645

There’s a link form the video to the GameDevNation.com site where you can download the entire article plus sample code. You have to be a member, but that’s free.

Jay
[import]uid: 9440 topic_id: 8987 reply_id: 36366[/import]