如何检测用户是否在 pygame 中双击了? [英] How can I detect if the user has double-clicked in pygame?

查看:53
本文介绍了如何检测用户是否在 pygame 中双击了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以检查是否有左键点击

I know I can check if there was a left click

event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT

但是我如何检查他们是否双击了?还有什么方法可以检查用户是向前还是向后移动滚轮?

but how can I check if they double clicked? Also is there any way to check if the user moved the scroll wheel forward or backwards?

推荐答案

我从未使用过 pygame - 但是:

I've never used pygame - but:

  • 检测双击: 猜测一下,不是立即处理每次点击,而是应用 50 毫秒的延迟,看看在那段时间是否有另一个点击事件.用户可能不会注意到 50 毫秒的延迟.

  • Detecting double clicks: at a guess, instead of processing each click immediately, apply a 50ms delay and see if you get another click event in that time. The user probably won't notice the 50ms delay.

区分向上/向下滚轮:查看关于此文档页面. 显然定义了五个按钮 - 左、中、右、滚轮向上和滚轮向下.也就是说,您可以像捕获左键单击一样捕获滚轮事件 - 您只需要查找 SCROLL_UP 或类似的而不是 LEFT.

Distinguishing between scrollwheel up/down: see the comments on this documentation page. Apparently there are five buttons defined - left, middle, right, scrollwheel-up and scrollwheel-down. That is, you can capture scrollwheel events the same way you're capturing left clicks - you just need to look for SCROLL_UP or similar instead of LEFT.

查阅文档以确切了解 SCROLL_UP 的名称.

Look up the documentation to find out exactly what SCROLL_UP is called.

这篇关于如何检测用户是否在 pygame 中双击了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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