Hello, I'm trying to implement zoom gesture for my game. I tried various methods on implementing this but no avail. My quick guess is to do it in love.touchmoved callback but I have no idea how. Any help is appreciated.
This is the gesture I wanted. You can see both of my fingers as black large dots.
I only need the basic concept/explanation how to do it. Code snippet that uses gamera is plus point but not necessary.
Implementing Firefox's Pinch Zoom Gesture
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Implementing Firefox's Pinch Zoom Gesture
Profile. Do you encounter crashes in LÖVE Android and wanna send me logcats? Please hit me up in LÖVE Discord and send the full logcat file!
Re: Implementing Firefox's Pinch Zoom Gesture
I've written a library to handle pinch gestures. It's incomplete because I'm stuck at something and I don't know how to solve it, but my library handles zoom, pan and rotation, all of them optional. I can hand you the WIP library if you think it can be useful for you. It produces values for a Löve transform, with position, rotation, scale and origin but no shear. I'm not sure how easy or hard will it be to adapt that to gamera. It should be simple to adapt it to cam11.
For pure zoom, the basics are as follows. Calculate the ratio between the initial distance between the fingers and the initial zoom, and use that to determine the final zoom as the distance between fingers varies via a simple cross-multiplication (the ratio should remain constant).
Panning is more complex. My library offers several options for what to use as hook, but the most straightforward one is the middle point between the fingers. You transform the initial middle point between both fingers to world coordinates and store that position; then, as the fingers move and the centre moves, you need to work backwards from the new position of the centre between the fingers, such that when transforming it to world coordinates, it produces the same initial point.
I assume you don't need rotation.
Re: Implementing Firefox's Pinch Zoom Gesture
It took me few days, but thanks I finally got it right.
Profile. Do you encounter crashes in LÖVE Android and wanna send me logcats? Please hit me up in LÖVE Discord and send the full logcat file!
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests