[英]On Android, how can I tell the location of a second finger that isn't moving but is touching the screen when the first finger releases from the screen
I'm using Java in Android.我在 Android 中使用 Java。 I'm having trouble explaining this so I'll try again.
我无法解释这一点,所以我会再试一次。
1 finger touches the screen and I use the event.getX()/Y() to get its cords.一根手指触摸屏幕,我使用 event.getX()/Y() 来获取它的绳索。
Another finger touches the screen and I'm still getting the X/Y of the first finger.另一根手指触摸屏幕,我仍然得到第一根手指的 X/Y。
Now the first finger is removed from the screen, however the second finger has yet to move and so it doesn't trigger the ACTION_MOVE and I can't get the event.getX()/Y() yet.现在第一根手指已从屏幕上移除,但第二根手指尚未移动,因此它不会触发 ACTION_MOVE,我还无法获取 event.getX()/Y()。
I want to know, how can I make it so even if the second finger hasn't moved yet how I can get it's X and Y as soon as the first finger releases from the screen.我想知道,即使第二根手指还没有移动,我怎么能做到这一点,一旦第一根手指从屏幕上松开,我怎么能得到它的 X 和 Y。 As of right now I'm having my character move towards the finger, and I have found it is quite common for this to happen and when it does the character continues to move towards the location of where the first finger left off until you move your finger slightly.
截至目前,我正在让我的角色向手指移动,我发现这种情况很常见,当它发生时,角色会继续向第一根手指离开的位置移动,直到你移动你的手指手指轻轻。 It happens enough to make it a problem, especially for what I'm trying to do.
这足以使它成为一个问题,尤其是对于我正在尝试做的事情。
I had the same problem when I was retrieving the position touched like this:我在检索 position 时遇到了同样的问题:
CGPoint touchLocation = CGPoint.make(event.getX(), event.getY();
Fixed it by using:通过使用修复它:
CGPoint touchLocation = CGPoint.make(event.getX(event.getPointerCount()-1), event.getY(event.getPointerCount()-1));
MotionEvent has more details for the second finger. MotionEvent 有更多关于第二根手指的细节。 Do review the documentation.
请查看文档。
look at the values in event.getX(1) and event.getY(1) methods.查看 event.getX(1) 和 event.getY(1) 方法中的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.