Pinch, double tap touch input

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
dan369
Prole
Posts: 44
Joined: Tue Apr 15, 2014 10:53 pm

Pinch, double tap touch input

Post by dan369 »

hi, i was wondering if there was any simple library or sample code for achieving a pinch to zoom style of input and a simple double tap action?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Pinch, double tap touch input

Post by raidho36 »

I have a huge daunting library posted here that does tons of touch input stuff, you can try your luck with it.

The way you detect gesture is by keeping track of pressed touches and the way they move. Usually simply tracking any two touches as gesture would work, although it it's a buggy way of doing it. Once you have a gesture, you can track it's "rotozoom", i.e. angle and distance simultaneously. If you need so, you can lock onto zoom if you detect greater distance change than angle change, or rotation if angle difference is greater than distance difference. Or if you only need zoom or rotation and so you ignore the other part. Double tap is a bit trickier, you can't do it without keeping track of all recently released touches. When a tap is made, you check it distance-wise and time-wise against all recent other taps and if it's close and quick enough you register it as double tap.
dan369
Prole
Posts: 44
Joined: Tue Apr 15, 2014 10:53 pm

Re: Pinch, double tap touch input

Post by dan369 »

Do you have a link at hand to that library?
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Pinch, double tap touch input

Post by raidho36 »

User avatar
Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

Re: Pinch, double tap touch input

Post by Marty »

raidho36 wrote: Sun Jun 25, 2017 1:35 pm https://github.com/raidho36/love-multitouch

While I was looking for it, I found this: https://github.com/Hau-Hau/GestureLib-Love2D
However, yours works with shapes, but you reported an issue https://github.com/raidho36/love-multitouch/issues/1 you didn't find a solution to this?

Also, how can I determine the X, Y, dtX and dtY on the Haxe Gesture port? (GestureLib-Love2D) The example is way too thin.
Visual Studio Code TemplateRichLÖVE Mobile (AdMob+UnityAds+PlayGamesServices+GameCenter)Add me on Discord

───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
───█▒▒░░░░░░░░░▒▒█───
────█░░░░░░░░░█────
▄▄──█░░░▀█▀░░░█──▄▄
█░░█▀▄░░░░░░░▄▀█░░█
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Pinch, double tap touch input

Post by raidho36 »

Well the code works, it's just it doesn't feel very optimal - pretty sure it can be done more efficiently! As for the other library - no idea.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: Pinch, double tap touch input

Post by pgimeno »

I think the problem is in the interface. I don't think you can make it any better with that interface. Something Löve-style would be more optimal: let the user apply scaling, rotation and shear in the order they prefer, and track these in a matrix.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Pinch, double tap touch input

Post by raidho36 »

As I said, I tried doing it that way and it's simply more computationally expensive to do the same job. The issue stays open until there's a computationally cheaper way of doing it. The current setup has 8 multiplications and 10 additions. Myself I found that's impossible to beat, not with using matrices anyway. Best of luck to whoever is smarter than that.
User avatar
Marty
Citizen
Posts: 89
Joined: Mon Dec 04, 2017 1:47 am
Location: Germany

Re: Pinch, double tap touch input

Post by Marty »

raidho36 wrote: Fri Feb 09, 2018 7:01 pm Well the code works, it's just it doesn't feel very optimal - pretty sure it can be done more efficiently! As for the other library - no idea.
Thank you for your statement, before using it I will consider performance tests.
Visual Studio Code TemplateRichLÖVE Mobile (AdMob+UnityAds+PlayGamesServices+GameCenter)Add me on Discord

───▄▀▀▀▄▄▄▄▄▄▄▀▀▀▄───
───█▒▒░░░░░░░░░▒▒█───
────█░░░░░░░░░█────
▄▄──█░░░▀█▀░░░█──▄▄
█░░█▀▄░░░░░░░▄▀█░░█
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Pinch, double tap touch input

Post by raidho36 »

modiX wrote: Sun Feb 11, 2018 8:59 pm Thank you for your statement, before using it I will consider performance tests.
Oh don't worry about that one, it's pretty fast. In fact it's slightly faster than forward transformation using standard approach (matrices).
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 54 guests