Hello again,
Let’s assume that you have one object that senses touch… this could be some object you drag, or even the stage (screen) itself. What I would do is monitor the number of touches that is currently on the object, increasing the count each time a touch “began” occurs, and decreasing each time a touch “ended” occurs.
So, imagine if the user touches one finger down. The count goes up to 1. Then they touch again… it goes up to 2. Then they remove the first finger: count reduces back to 1. Then they touch down 3 more fingers… count goes up to 4. Then they remove all four fingers, count goes to 0. Etc. etc… simple enough counting system.
Now, with this count “attached” as a parameter to the object, you can manage if you handle more than 1 touch (which you don’t want to). I would use this procedure as the first within your touch function:
local object = --a display object, button, whatever
object.touchCount = 0
local function example( e )
local t = e.target
local phase = e.phase
if ( phase == "began") then
t.touchCount = t.touchCount + 1
elseif ( phase == "ended" ) then
t.touchCount = t.touchCount - 1
end
if ( t.count \> 1 ) then return --effectively cancel any further processing in this function
else
--proceed with your touch action
end
return true --prevent touch from extending through to objects behind
end
This should prevent any action from occurring on more than one touch… however, it might not solve your issue exactly. Test it out and see if it helps at all.
Best regards,
Brent [import]uid: 9747 topic_id: 32178 reply_id: 128237[/import]