OnTouchListener 比 OnClickListener 快吗? [英] Is OnTouchListener faster than OnClickListener?

查看:69
本文介绍了OnTouchListener 比 OnClickListener 快吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个 Android 2D 游戏,这是多人游戏,两个玩家使用同一个屏幕...

I'm making an Android 2D game, which is multiplayer and two players use the same screen...

每个用户都有几个按钮来控制他们的播放器,有时他们应该尽可能快地点击这些按钮......这就是我遇到的问题!

Each user has a couple of buttons to control their player, and sometimes they should click those buttons as fast as they can... And that's where I have problems with!

我在真实设备上测试了该应用程序,并且(我不确定这一点,但是)我认为当两个用户同时点击多个按钮时,其中一些点击将不起作用!我可以看到玩家移动缓慢...

I tested the app on a real device, and (I'm not sure about this, but) I think when both users click multiple buttons at the same time, some of these clicks won't work! I can see that players move slowly...

这是因为设备(三星 Galaxy S3)吗?还是因为我使用的 OnClickListener ?在这种情况下 OnTouchListener 更好吗?或者它们是一样的?

Is this because of the device (which is a Samsung Galaxy S3)? Or because of the OnClickListener I used? Is OnTouchListener better in this case? Or they're the same?

推荐答案

要调用 OnClickListener,用户必须按下然后释放按钮.
使用 OnTouchListener 您可以检查 ACTION_DOWN 事件,这意味着您的应用程序无需等待 2 个事件即可做出反应.所以理论上OnTouchListener 应该更快",如果你正确地实施它.

For an OnClickListener to be called the user must press then release the button.
With an OnTouchListener you can check for an ACTION_DOWN event, and this means your application will not need to wait for 2 events before it can react. So in theory the OnTouchListener should be "faster" if you implement it right.

希望我有所帮助:)

这篇关于OnTouchListener 比 OnClickListener 快吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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