检测手势是顺时针还是逆时针

时间:2013-01-07 12:40:37

标签: android gesture

我在课堂上使用OnGestureListener。 我想知道我做的手势是顺时针还是逆时针,并希望对这些手势执行不同的任务。 OnGestureListener是否提供此功能?我怎么能这样做?

2 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

 if(prediction.size() > 0){
  String gesturePerformed = prediction.get(0).name;
  if(gesturePerformed.equals("up")){
   myForeground.canvasUp();
   Toast.makeText(MyGameActivity.this,
     "up", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("down")){
   myForeground.canvasDown();
   Toast.makeText(MyGameActivity.this,
     "down", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("left")){
   myForeground.canvasLeft();
   Toast.makeText(MyGameActivity.this,
     "left", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("right")){
   myForeground.canvasRight();
   Toast.makeText(MyGameActivity.this,
     "right", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("clockwise")){
   myForeground.canvasClockwise();
   Toast.makeText(MyGameActivity.this,
     "clockwise", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("anti-clockwise")){
   myForeground.canvasAntiClockwise();
   Toast.makeText(MyGameActivity.this,
     "anti-clockwise", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("enlarge")){
   myForeground.canvasEnlarge();
   Toast.makeText(MyGameActivity.this,
     "enlarge", Toast.LENGTH_LONG).show();
  }else if(gesturePerformed.equals("reduce")){
   myForeground.canvasReduce();
   Toast.makeText(MyGameActivity.this,
     "reduce", Toast.LENGTH_LONG).show();
  }
 }

}

来源:HTTP://android-coding.blogspot.in/2012/03/gestures-detection-and-canvas-scale.html