Android的 - 在触摸同一时间两个按钮 [英] Android - touch two buttons at same time

查看:148
本文介绍了Android的 - 在触摸同一时间两个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是触及两个按钮在同一时间的最好方法?我的工作有一个按钮的应用程序,如D-垫和跳跃键,来移动你的性格。现在我只是用普通的按钮和与OnClickListener处理它们。我有当我运行,需要在同一时间跳跃,或者如果我运行到正确的问题,那么要向左走,而不必来接我的手指。我知道这是可能的,因为它的工作原理像索尼克CD和其他一些游戏大师。任何帮助将大大AP preciated。

What is the best way to touch two buttons at the same time? I am working on an app that has buttons, like a D-pad and a jump button, to move your character around. Right now I am just using normal buttons and handling them with an OnClickListener. I am having problems when I am running and need to jump at the same time, or if I am running to the right, then want to go left without having to pick my finger up. I know this is possible because it works greats on game like Sonic CD and some others. Any help would be greatly appreciated.

推荐答案

的onclick只释放火灾。相反,使用触摸事件处理程序,这样,当他们接触时,你得到的事件。但是,请注意,并非所有的设备都有多点触控,因此他们并非所有人都能够正确处理双触摸情况。他们将提供触摸事件,而不是两个。另外请注意,您可能会收到多个指针触摸事件中,并且将必须决定哪些是你的为每个按钮如果该事项。

OnClick fires only on release. Instead use the touch event handlers so that when they touch occurs, you get the events. However, note that not all devices have multitouch, and thus not all of them will be able to handle the double-touch case correctly. They will provide touch events, but not two of them. Also note that you may receive multiple "pointers" within a touch event, and will have to decide which is "yours" for each button if that matters.

这篇关于Android的 - 在触摸同一时间两个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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