SimpleGesture onFling maximum for different devices?

Put your problem here if it does not fit any of the other categories.

SimpleGesture onFling maximum for different devices?

Postby JM33 » Fri Feb 03, 2012 9:28 am

My application uses android's simplegesturelistener to get a fling gesture. The onFling returns a velocityX and velocityY value. These values are a measure of pixels per second.

Everything is working as expected, but my issue is that the velocity values seem to have a maximum value. This value is different on different devices. For example, on a Motorola droid, the maximum velocity I can achieve is 4000. On a galaxy nexus the maximum is 8000.

My game uses this velocity to determine the speed a ball is kicked. I was using this maximum value to limit how hard the ball could be kicked. Since the maximum changes on different devices, the kick is not consistent. I have also had users tell me that on other devices they cannot get the ball to go far enough to reach the goal, no matter how hard they fling.

Is there any way to check the maximum of this gesture so that I can calculate the maximum for each device? I tried the ViewConfig.getScaledmaximumFlingVelocity, but that seems to give a completely seperate value.

At this point I am considering creating my own fling gesture, or simply coding a limit that is much lower. Unfortunately the latter would change the feel of the kick, reducing its sensitivity. However a consistent fling on any device is more important.

Any help would be appreciated!
JM33
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Nov 12, 2010 8:35 pm

Top

Re: SimpleGesture onFling maximum for different devices?

Postby Phyll » Fri Feb 03, 2012 10:57 pm

Hi JM33,

Seems to me like maybe you should use the getScaledMinimumFlingVelocity and getScaledMaximumFlingVelocity to normalize any fling values coming from your app. Say, like making a percentage out of the value and then using that in your app. I was also trying to figure out just what those numbers are. Seems like a value below the minimum won't show up in the onfling method and same for flings that are greater than maximum. Is that right? Also might have something to do with the resolution of the display since it is in pixels per second you may need to make the game move faster or slower for that reason or at least factor it in.

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Re: SimpleGesture onFling maximum for different devices?

Postby JM33 » Sat Feb 04, 2012 9:06 am

Thats what I would have thought. However, it seems that the values from ViewConfig.getScaledFlingMaximum do not relate well to the values for velocityX,Y from the onFling (GestureDetector may be reading the screen size differently than ViewConfig?).

For motorola droid:
ViewConfig.getScaledFlingMaximum = 6000
maximum velocityX,Y = 4000
screen size 854x480

For Galaxy Nexus:
ViewConfig.getScaledFlingMaximum = 16000
maximum velocityX,Y = 8000.
screen size 1280x720

At first with the nexus I thought maybe it was getting half value but when I checked the droid it threw that way off. My app runs in fullscreen so the screen size doesn't seem to relate either. I think I am going to just make my own fling code to avoid the unknown, and was the only reason I was using SimpleGestureListener.
JM33
Junior Developer
Junior Developer
 
Posts: 10
Joined: Fri Nov 12, 2010 8:35 pm

Re: SimpleGesture onFling maximum for different devices?

Postby Phyll » Sat Feb 04, 2012 12:01 pm

Hi JM33,

Here is a fairly large discussion about using this feature:

http://stackoverflow.com/questions/9373 ... -detection

Hope this helps.

Phyll
Phyll
Master Developer
Master Developer
 
Posts: 648
Joined: Fri Oct 14, 2011 11:19 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 21 guests