开发者

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. I'm having trouble explaining this 开发者_如何学Cso I'll try again.

1 finger touches the screen and I use the event.getX()/Y() to get its cords.

Another finger touches the screen and I'm still getting the X/Y of the first finger.

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.

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. 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.


MotionEvent has more details for the second finger. Do review the documentation.

look at the values in event.getX(1) and event.getY(1) methods.


I had the same problem when I was retrieving the position touched like this:

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));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜