- Home /
How to log a finger move?
I made an 2D application on Android and I'd like to log if my finger is moving down, up, right or left. I don't know how to implement it in my code. (ex. when I move my finger left the object turn left)
Thanks in advance for youre advices.
Answer by HenryStrattonFW · Feb 18, 2018 at 09:25 AM
For touch input each of the touches contain a value called deltaPosition, this is a vector representing the movement of that input since the previous frame, this can be used as a crude method for detecting the direction of the inputs movement. However for slower movements with fingers being the big clunky things they are may be a bit noisy.
Another option is to store the input position and then at another time in the future compare the current position to the previous position to work out the change. The time you choose in the future could be anything, a few frames, half a second, or wait until the touch is ended/cancelled.
Hope this helps give you an idea of how to determine the direction of a touch input.