Touch move on object

Hi,

Right now I have a button in my game, which registers to a touch event.  If I move my finger off the button (after touching it), and release, the touch event does not end.

I have explored the onMove listener to disable the touch, however that doesn’t seem to work well with my goal. I want to try to make it so that all touches (and movements) contained within the button keep the button on, then if the finger is moved out of the button/is released, the onRelease function is triggered.

If anybody has any thoughts as to how to fix this that would be great.

Thanks.

You need to use setFocus()

See how I did it in this example from the Corona Geek Hangout:

http://github.com/roaminggamer/CoronaGeek/blob/master/Hangouts/Tips_and_Tricks/two_touch_steering/steering01_two_touch/main.lua

Touch handler starts on line 22

Get all code here:

http://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/Tips_and_Tricks/two_touch_steering.zip

PS - The example given for setFocus() is a function listener, mine is a table listener.  These are merely different ways of approaching a touch event.  Also, mine is multitouch safe, whereas the one shown for setFocus() is not (it can however be easily modified to make it so).

I had this EXACT same problem. I ended up using the widget.newButton which does set focus and does call the “ended”
phase when released off button.

–InfiSnyp

Thank you so much! I got it all working now :slight_smile:

You need to use setFocus()

See how I did it in this example from the Corona Geek Hangout:

http://github.com/roaminggamer/CoronaGeek/blob/master/Hangouts/Tips_and_Tricks/two_touch_steering/steering01_two_touch/main.lua

Touch handler starts on line 22

Get all code here:

http://github.com/roaminggamer/CoronaGeek/raw/master/Hangouts/Tips_and_Tricks/two_touch_steering.zip

PS - The example given for setFocus() is a function listener, mine is a table listener.  These are merely different ways of approaching a touch event.  Also, mine is multitouch safe, whereas the one shown for setFocus() is not (it can however be easily modified to make it so).

I had this EXACT same problem. I ended up using the widget.newButton which does set focus and does call the “ended”
phase when released off button.

–InfiSnyp

Thank you so much! I got it all working now :slight_smile: