为了账号安全,请及时绑定邮箱和手机立即绑定

使用 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 关注
  • 100 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信