TouchHit(1) registered, but not TouchHit(0)?

Monkey Forums/Monkey Bug Reports/TouchHit(1) registered, but not TouchHit(0)?

sandfella(Posted 2013) [#1]
Here's my test code:


I run it on android and tried tapping the screen with two fingers (first left, then right, then left etc... quickly), and I got the following debug info:



These lines were most interesting:
17 I/[Monkey]( 1120): hit[0]0
18 I/[Monkey]( 1120): coord x[0]522.0
19 I/[Monkey]( 1120): hit[1]1
20 I/[Monkey]( 1120): coord x[1]332.0


How is it possible for touchhit(1) to register a press, since there's no touchhit(0) on that nor on the previous round (lines 9 and 17)?

To my understanding, the line 17 should have "hit[0]1", and line 19 should be "hit[1]0".

Also, why I can get coordinates, even when there's no touch (not a problem, just curious)

What am I missing here?

Documentation says about TouchHit:int(index:int)



marksibly(Posted 2013) [#2]
Not quite sure what you mean, but finger '0' begins touching at line 1, while finger '1' begins touching at line 19 - after this, both fingers are touching.

TouchHit only returns 1 the first time a finger makes contact. After that, it will return 0 until the finger is released and then pressed again.

Use TouchDown instead to determine if finger is 'continuously' in contact.

> Also, why I can get coordinates, even when there's no touch (not a problem, just curious)

Because it's convenient! I guess reading TouchX/TouchY could cause a runtime error/exception if finger isn't down, but I'm not sure what that'd achieve.


sandfella(Posted 2013) [#3]
Ok, I think I got it... thanks Mark.

I thought I lifted finger '0'

(as for the TouchX/Y, doesnt really matter, was just curious :)