After some struggling I managed to have both multitouch and swipe detection, here's what I found and how I did it:
InputEventScreenTouch and the
InputEventScreenDrag classes are good for detecting multiple touches, as you can see from the index property. You can also use
TouchScreenButton as long as you don't need to detect a swipe gesture;
- you can detect multitouch events using
Area2D._input_event, just connect the corresponding signal to a function and write your code in there.
So I used two Area2Ds, connected the input_event signal and I wrote:
func _on_GunArea_input_event( viewport, event, shape_idx ):
if event is InputEventScreenTouch and event.pressed:
swipe_start = event.position
if event is InputEventScreenTouch and not event.pressed:
Basically all you need is check if the event is an
InputEventScreenTouch event type and check the status of the
pressed property to see when the user starts touching and when he releases that touch. Then the calculate_swipe function checks if the input is a swipe and eventually emits a signal, as suggested in this post by another user.
I know this sounds pretty simple, but I'm sure that trying to check the
pressed property did not work at all. Maybe it was because I was using an alpha build, maybe I was just burned out I missed something, but using this approach again worked with the stable. And it's so simple I can't believe how much time I wasted trying a workaround on my own!
Anyway, I hope this will help future newbies like me.