In my game I integrate like so: (Please assume all variables to be declared)
sprite.xTimeInSeconds = 5.0; //Time in seconds it should take this object to cross screen sprite.xVelocity = 1f/xTimeInSeconds;
And then I move it like so:
Then I simply render the sprite at those coordinates:
sprite.draw(); //Uses sprite's internal 'x' which was set above
So, everything within the game itself works fine - ie. all movement is correctly scaled regardless of device, but now I'm trying to write my own swipe/fling touch control system for a menu.
The menu does work - the user can place finger on screen, move up and down and when they release their finger, the menu keeps scrolling(* see below). If they then press their finger down again, the scrolling stops immediately, as one would expect.
The only thing I'm having problems with is how to 'decelerate' the scrolling when the user releases their finger. At the moment, it keeps scrolling at the same speed until it reaches it's limits or the user taps the screen to stop it.
Within my touch-scroll method, I'm simply detemining how much the users finger has moved by and then moving my objects by the same amount. What I need to know (and can't figure out), is how can I - from knowing only the amount of pixels moved, work out the 'time' variable above? (once I have this I can then decelerate at a scaled amount on all devices).