【问题标题】:Detect whether a gesture was clockwise or anticlockwise检测手势是顺时针还是逆时针
【发布时间】:2013-01-07 12:40:36
【问题描述】:

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

【问题讨论】:

    标签: android gesture


    【解决方案1】:

    【讨论】:

    • 不,我不明白,我正在寻找 vecotr 乘法逻辑来检测 claock 明智或反时钟明智的逻辑
    【解决方案2】:
     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

    【讨论】:

    • 不,我不明白,我正在寻找 vecotr 乘法逻辑来检测 claock 明智或反时钟明智的逻辑
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多