亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 Processing 檢測 android 上的捏合動作

使用 Processing 檢測 android 上的捏合動作

天涯盡頭無女友 2022-12-15 16:47:24
我正在開發一個用 Processing 3 編寫的 android 應用程序。它需要能夠在啟動捏合動作“放大”時增加一個變量,并在“縮小”時減少。在 Processing 中是否有內置的方法來執行此操作,如果沒有,有人可以在正確的方向上給我提示以創建我自己的解決方案嗎?提前致謝。
查看完整描述

1 回答

?
炎炎設計

TA貢獻1808條經驗 獲得超4個贊

看看科泰庫-KetaiGesture

為加工草圖提供手勢識別服務。要接收手勢事件,草圖可以定義以下方法:

...

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

查看完整回答
反對 回復 2022-12-15
  • 1 回答
  • 0 關注
  • 136 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號