Touch moves outside initial object

Hi I’m not sure if there’s an alert/event or something that will say if a touch moves outside of the initial object.

I want the user to press and hold an object to pick it up, but if they are holding the object and their pointer moves outside the bounds I want the object to know that. I would think this would be a good use for event.phase == “cancel”.

Is there anything that does this or will I have to use a hack with the physics object or perform some math calculations?

Thanks [import]uid: 27076 topic_id: 18765 reply_id: 318765[/import]

If your object can be approximated by the content rectangle, you can do a manual check by comparing touch.x, y to contentBounds.xMin, xMax, yMin, yMax. OR just transform touch.x, y by contentToLocal and compare against the 0, 0, width, height rectangle.

Circles are also very easy to check since you just need to check square distance from center. For other shapes, it becomes much more complicated. :wink: In that case, you may be able to rely on physics system (not that it’s pretty since Corona doesn’t support ray casts/region queries). [import]uid: 58849 topic_id: 18765 reply_id: 72270[/import]