Getting screen resolution independent swipe/drag distance
I'm building a very simple basketball game where the player will launch a basketball based on a swipe/drag. I can get the start and end point of the swipe, as well as the time it took to complete. I use distance over time to get the speed and use that value to build a vector to launch the ball.
The problem I have is the following:
On a device with a resolution of 1280x720 the pixel distance of the swipe is different than on a device with a 1920x1080 resolution. On a device with a higher resolution, the player would have to do a much shorter swipe.
What I would like to do is get the screen resolution so I can divide the pixel distance by the screen height. That way it would work the same for any resolution.
So my question is:
One thing I haven't tried but will give a shot is:
I'm guessing that way it would also work on any resolution, but somehow seems a bit hacky?
Follow this question
Once you sign in you will be able to subscribe for any updates here