I’m having trouble figuring out how the multitouch class works, and even more trouble trying to get it to read only one touch on the screen and not any more. I’ve added the relevant code below, and would appreciate if someone would help me on how to ignore inputs from other fingers, so that the circle follows only one finger and not any others.
I also tried to edit the code myself, but it didn’t help.
function setup()
touches = {}
taps = 0
end
-- This function gets called whenever a touch
-- begins or changes state
function touched(touch)
if touch.state == ENDED then
-- When any touch ends, remove it from
-- our table
taps = 0
touches[touch.id] = nil
else
-- If the touch is in any other state
-- (such as BEGAN) we add it to our
-- table
touches[touch.id] = touch
if taps >= 2 then
touches[touch.id] = nil
end
if touch.state == BEGAN then
taps = taps + 1
end
end
end
function draw()
background(0, 0, 0, 255)
print(taps)
for k,touch in pairs(touches) do
-- Draw ellipse at touch position
ellipse(touch.x, touch.y, 100, 100)
end
end