Dearest Livecoders,
I am doing some experiments with a frontscript for detecting some usual mobile gestures. However, I am stuck on a strange oddity while dealing with pinch gestures. I have basically applied what I saw on the tutorial at http://lessons.runrev.com/s/lessons/m/4 ... nch-motion, with some differences though.
1) The very first thing my touchStart handler does is to save the touch ID in a script local array and the mouseLoc under a nested key. Like touchesArray [tID]["initialLoc"] .
2) The touchMove handler just passes the message if the array does not contain two elements. If there are two elements (i.e., two simultaneous touches), a Pitagoras function is used for calculating the initial distance of both touches (their coordinates stored in the array of touches) and the current distance between them. Then these distances are compared, other calculation is done, etc.
But apparently there is a bug in the detection of the two touches. After much testing, I found that the initial coordinates for the second touch are reported as if it happened too close to the first touch -- no matter how far the touches actually happen.
Tests done with Livecode 6.5.2 and 6.6 RC1, a Motorola Moto G with Android Kit Kat. In the preOpenStack handler, the fullscreenmode of the stack is changed to "exactFit".
Might you folks have a clue on what's going on?
Thank you very much!
Fabricio Rocha
Brasilia, Brasil
Problem detecting the second touch of a pinch gesture
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 25
- Joined: Sun Jan 19, 2014 8:53 pm
-
- Posts: 25
- Joined: Sun Jan 19, 2014 8:53 pm
Re: Problem detecting the second touch of a pinch gesture
Hi all,
Some more information which might help. Here is a test code, placed in the app's first card, which shows the described problem:
I just tested this in LiveCode 6.6 RC1. This time I did not change the stack's "fullscreenmode", and I still get very strange results in the answer dialog. In the Standalone Applications Settings, I had "Multitouch" and "Multitouch Distinct" requirements selected, but I presume this does not matter. As I actually found the problem in LC 6.5, I think I don't need to test this code there.
It really looks as a bug, if there is nothing wrong with the described algorithm (I suspect "the mouseLoc" might be returning the result of the wrong touch ID).
(EDIT: Made a second test right after. Instead of storing the mouseLoc with the touchStart handler, now I stored the tX and tY passed to the touchMove handler. And it seems to work as expected. Now I think the mouseLoc is not suitable for dealing with multitouches. Is this an expected behaviour?)
Could you please try and confirm?
Thank you very much!
Fabricio Rocha
Brasilia, Brasil
Some more information which might help. Here is a test code, placed in the app's first card, which shows the described problem:
Code: Select all
local touches
on touchStart tID
put the mouseLoc into touches[tID]["pos"]
end touchStart
on touchMove tID, px, py
if the number of lines of the keys of touches <> 2 then
pass touchMove
else
put line 1 of the keys of touches into t1
put line 2 of the keys of touches into t2
answer "touch 1:" & touches[t1]["pos"] & return & "touch 2:" & touches[t2]["pos"]
end if
end touchMove
on touchEnd tID
delete variable touches[tID]
end touchEnd
It really looks as a bug, if there is nothing wrong with the described algorithm (I suspect "the mouseLoc" might be returning the result of the wrong touch ID).
(EDIT: Made a second test right after. Instead of storing the mouseLoc with the touchStart handler, now I stored the tX and tY passed to the touchMove handler. And it seems to work as expected. Now I think the mouseLoc is not suitable for dealing with multitouches. Is this an expected behaviour?)
Could you please try and confirm?
Thank you very much!
Fabricio Rocha
Brasilia, Brasil