[英]How to get mouse wheel speed or mouse wheel notches moved in libgdx?
I know that LibGDX offers interfaces like InputProcessor
and classes like InputAdapter
.我知道LibGDX提供了像InputProcessor
这样的接口和像InputAdapter
这样的类。 They do have a scrolled method which can be override and be activated when the mouse wheel is moved.它们确实有一个滚动方法,可以在移动鼠标滚轮时覆盖和激活。
It returns a boolean
value and take an integer
for the argument.它返回一个boolean
值并为参数取一个integer
。 The integer will either be -1 or 1 depending on the mouse wheel's scrolling direction.根据鼠标滚轮的滚动方向,整数将为 -1 或 1。 -1 is up and 1 is down. -1 上升,1 下降。
That's nice, but not fully what I need.这很好,但不完全是我需要的。 I need to figure out the mouse wheel's scrolling speed .我需要弄清楚鼠标滚轮的滚动速度。 Java does have a MouseWheelListener
that allows one to find out how many notches the wheel has spun. Java 确实有一个MouseWheelListener
可以让人们知道轮子旋转了多少个槽口。 I tried implementing that into LibGDX
and it just didn't work.我尝试将其实施到LibGDX
,但没有奏效。
Thanks in advance!提前致谢!
You can track the wheelattacks/second by counting the mousewheel-attacks via the scrolled() method in the inputprocessor and reset the timer at every call of the render() method.您可以通过 inputprocessor 中的 scrolled() 方法计算鼠标滚轮攻击来跟踪滚轮攻击/秒,并在每次调用 render() 方法时重置计时器。 attacks*delta should give you the speed.攻击*增量应该给你速度。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.