android– 可以处理多点触控吗?

android– 可以处理多点触控吗?,第1张

概述我是Processing的新手,我想在Android模式下运行我的草图.我希望它同时支持多个触摸.我想知道是否有人可以指导我这个问题:如何让草图支持多次触摸?解决方法:这是一个完整的例子:/***androidMultiTouch.pde*ShowsthebasicuseofMultiTouchEvents**///----------

我是Processing的新手,我想在AndroID模式下运行我的草图.我希望它同时支持多个触摸.

我想知道是否有人可以指导我这个问题:

如何让草图支持多次触摸?

解决方法:

这是一个完整的例子:

/* * * androIDMultitouch.pde * Shows the basic use of Multitouch Events * *///-----------------------------------------------------------------------------------------// importSimport androID.vIEw.MotionEvent;//-----------------------------------------------------------------------------------------// VARIABLESint touchEvents;float xtouch[];float ytouch[];int currentPointerID = 0;boolean printFPS;//-----------------------------------------------------------------------------------------voID setup() {  size(displayWIDth, displayHeight);  orIEntation(LANDSCAPE);  background(0, 255, 0);  fill(0, 0, 244);  rect(100, 100, 100, 100);  stroke(255);  // Initialize Multitouch x y arrays  xtouch = new float [10];  ytouch = new float [10]; // Don't use more than ten fingers!}//-----------------------------------------------------------------------------------------voID draw() {  background(255, 0, 0);  for (int i = 0; i < xtouch.length; i++) {    ellipse(xtouch[i], ytouch[i], 150, 150);  }}//-----------------------------------------------------------------------------------------public boolean surfacetouchEvent(MotionEvent event) {  // Number of places on the screen being touched:  touchEvents = event.getPointerCount();  // If no action is happening, Listen for new events else   for (int i = 0; i < touchEvents; i++) {    int pointerID = event.getPointerID(i);    xtouch[pointerID] = event.getX(i);     ytouch[pointerID] = event.getY(i);    float siz = event.getSize(i);  }  // ACTION_DOWN   if (event.getActionMasked() == 0 ) {    print("Initial action detected. (ACTION_DOWN)");    print("Action index: " +str(event.getActionIndex()));  }   // ACTION_UP   else if (event.getActionMasked() == 1) {    print("ACTION_UP");    print("Action index: " +str(event.getActionIndex()));  }  //  ACTION_POINTER_DOWN   else if (event.getActionMasked() == 5) {    print("Secondary pointer detected: ACTION_POINTER_DOWN");    print("Action index: " +str(event.getActionIndex()));  }  // ACTION_POINTER_UP   else if (event.getActionMasked() == 6) {    print("ACTION_POINTER_UP");    print("Action index: " +str(event.getActionIndex()));  }  //   else if (event.getActionMasked() == 4) {  }  // If you want the variables for motionX/motionY, mouseX/mouseY etc.  // to work properly, you'll need to call super.surfacetouchEvent().  return super.surfacetouchEvent(event);}
总结

以上是内存溢出为你收集整理的android – 可以处理多点触控吗?全部内容,希望文章能够帮你解决android – 可以处理多点触控吗?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1097233.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存