So, I have the following body for my onFling() method:
public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX, float velocityY) {
try {
// Left swipe
if ( velocityX < -SWIPE_THRESHOLD_VELOCITY) {
if( velocityY < -SWIPE_THRESHOLD_VELOCITY) {
GameWindow.writeToOutput("northwest");
Log.d("Console","Wrote NW");
}
else
GameWindow.writeToOutput("west");
return true;
// Right swipe
} else if (velocityX > SWIPE_THRESHOLD_VELOCITY) {
if( velocityY < -SWIPE_THRESHOLD_VELOCITY) {
GameWindow.writeToOutput("northeast");
Log.d("Console","Wrote NE");
}
else
GameWindow.writeToOutput("east");
return true;
}
if ( velocityY > SWIPE_THRESHOLD_VELOCITY) {
GameWindow.writeToOutput("south");
return true;
}
if ( velocityY < -SWIPE_THRESHOLD_VELOCITY) {
GameWindow.writeToOutput("north");
return true;
}
} catch (Exception e) {
Log.e("YourActivity", "Error on gestures");
}
return false;
}
My issue has been that, I will do an up-left "fling", but the velocities will instead suddenly display in the logcat that I did a "fling" in the opposite direction. Could this be an emulator issue, or is my code not accurately measuring the direction of my gesture?