1 回答

TA貢獻1808條經驗 獲得超4個贊
為加工草圖提供手勢識別服務。要接收手勢事件,草圖可以定義以下方法:
...
onPinch(float x, float y, float r) - 中心的x,y,r是距離
使用捏合動作更改圓圈大小的代碼示例:
import ketai.ui.*;
import android.view.MotionEvent;
float ellipseWidth = 50;
float ellipseHeight = 50;
KetaiGesture gesture;
void setup() {
size(displayWidth, displayHeight);
gesture = new KetaiGesture(this);
}
void draw() {
orientation(PORTRAIT);
background(0);
fill(0);
stroke(255);
ellipse(width/2, height/2, ellipseWidth, ellipseHeight);
}
void onPinch (float x, float y, float d) {
ellipseWidth += d;
ellipseHeight += d;
}
public boolean surfaceTouchEvent(MotionEvent event) {
//Call this to keep mouseX and mouseY updated
super.surfaceTouchEvent(event);
//Forward the event to the class for processing
return gesture.surfaceTouchEvent(event);
}
希望這可以幫助!
https://i.stack.imgur.com/i1vVY.gif
添加回答
舉報