Android的多点触控干扰 [英] Android multi-touch interference

查看:108
本文介绍了Android的多点触控干扰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个空气曲棍球仿真机器人。对于多人模式,我跟踪了屏幕,效果很好,只要触摸点不明白关闭两个触摸事件。

I'm currently developing an air-hockey simulation for android. For the multiplayer mode I'm tracking two touch events on the screen, which works well as long as the touch points don't get to close.

当两个手指去收,机器人只承认一个触摸事件,在这两个点中间。

When the two fingers get to close, android only recognizes one touch event, in the middle of both points.

为了让事情变得更糟,有时机器人碰撞后弄乱的ID。

To make it even worse, android sometimes messes up the IDs after the collision.

我已经想过,估计下一个触摸点ANS手动分配的ID,没有任何人知道一个更好的办法,或知道某人谁已经编程方式解决了这个问题?

I already thought about estimating the next touch points ans assigning IDs manually, does anybody know a better way, or knows about somebody who already fixed this problem programmatically?

注:我测试上三星Galaxy S 3

NOTE: I'm testing on a Samsung Galaxy S 3

推荐答案

不一定对这个问题的逻辑修复,但一个可能的解决方案应用程序:

Not necessarily a logical fix to the issue, nevertheless a possible solution to the application:

如果我不是大错特错了,空气曲棍球游戏不应该让对手去打扰对方的游戏领域。如果我们假设一个粗边框跨屏幕的中心(在纵向模式下),那么我会不会被允许做任何超出边界,因此没有在跟踪我的手指后,到达边境线上没有意义的。

If I'm not completely mistaken, air-hockey games shouldn't allow opponents to intrude on each others game field. If we assume a thick border cross the center of the screen (in portrait mode), then I wouldn't be allowed to do anything beyond that border, hence there is no point in tracking my finger after it reaches the border line.

您封装跟踪触摸事件,将描述可能只是帮助你忽略无效的点(考虑到物理位置不相交,这是)有效的物理位置。

Encapsulating your tracked touch events into valid physical locations as described might just help you in ignoring invalid points (given that the physical locations doesn't intersect, that is).

您可能还必须保持接触矢量方向的跟踪:如果向量是从屏幕中心伸向最终这可能是对手闯入手指或你自己回来的手指。在两种情况下,他们应该不会影响冰球(也许)。

You might also have to keep track of direction of the touch vector: if the vector is stretching from the center of the screen towards "your end" it might be the opponents intruding finger or your own returning finger. In neither case should they affect the hockey puck (perhaps).

这篇关于Android的多点触控干扰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆