In my game, I control an object using touch event. When I touch the right half of the screen, the object rotates, when I touch the left half of the screen, the object moves. It works perfectly when it’s a single touch, but when I touch any side of the screen and then start touching the other side at the same time, it results in an unexpected, mixed-up behavior.
I guess my question is, how to separate or differentiate multiple touches one from the other.
system.activate( "multitouch" ) onTouch = function (event) if (event.phase == "began") then pX = event.x -- Get start X position of the touch print( "ID:"..tostring(event.id) ) if (event.x \> centerX) then --if the touch is in the right or left half of the screen xPos = "right" else xPos = "left" end elseif (event.phase == "moved") then local dX = (event.x - pX ) if (xPos == "right") then rotatePlayer(dx) else movePlayer(dX) end