I have been struggling with multi-touch and finally got it working, but on accident. I added a print statement in my event handler just for troubleshooting purposes and it caused my multi-touch listener to start doing what I wanted it to do. I asked on stackoverflow why this happened, but I didnt get a response so I’m re-posting it here. Here’s my original post:
function multitouchHandler(event) if ( "began" == event.phase ) then myTable[event.target.id] = true end if ( "ended" == event.phase ) then if thisObject == currentObject then removeObject() else print("This object isn't the current object.") endProgram() end end end
This is a multi-touch event handler that is called by two objects being touched at the same time. The code works and does what I want it to do, but I’m not sure why.
It actually started working when I got frustrating not knowing what was wrong so I added print() statements throughout my entire project to help me troubleshoot. To my surprise when I added the print() statements, multi-touch started working.
One by one I removed them until I figured out which one was actually causing my multi-touch listener to start working and it turns out to be the one in the above code. If I take out the print() statement, multi-touch stops working.
This isn’t the exact code in my program, but it’s summarized to act like the listener. I would like to know why the print() statement is needed. It seems to add a long enough ‘pause’ to make the multi-touch return the “if thisObject == currentObject” condition to true, but if that’s the case then I would think there is a better way to create this pause.
(currentObject is chosen by two objects being touched and then compared to the currentObject)