2013-01-07 64 views
2

我在課堂上使用OnGestureListener。 我想找出我做的手勢是順時針還是逆時針,並希望在這些手勢上執行不同的任務。 OnGestureListener是否提供此功能?我怎樣才能做到這一點?檢測手勢是順時針還是逆時針

回答

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

+0

不,我沒有得到它我正在尋找vecotr乘法邏輯檢測claock明智或反時鐘明智的邏輯 – Bora

相關問題