Reputation: 155
The touch event in Corona has 4 phases: "began", "moved" , "ended" and "cancelled". When does the event receive the "cancelled" phase? (I didn't find a function that you can cancel the event with it, you can just remove the listeners). And how can I use the "cancelled" event phase in application?
Upvotes: 2
Views: 1393
Reputation: 71
Basically if you are holding an object, button, etc. and you slide your finger off instead of releasing it that will be registered as 'canceled' which you can do what you wish with, usually the same as 'ended'
Example:
if event.phase == "began" then --Pressing the button
move = true
elseif event.phase == "canceled" then --sliding your finger off
move = false
elseif event.phase == "ended" then --Releasing the button
move = false
end
Upvotes: 1
Reputation: 5159
Corona SDK is an abstraction layer upon the top of iOS and Android; most design decisions will reflect upon the underlying platform.
It would seem the touch event implements the UITouch object (and whatever the equivalent is on Android). Searching Google for "iphone uitouch cancelled" resulted in this question, which should answer yours.
If you need to manually "cancel" an event, simply store a flag in an associated object (or in the touch event, if it's a simple table) and check it when "moved" or "ended" is called.
(Disclaimer: I have never used Corona, nor developed for mobile platforms.)
Upvotes: 1