确定LWJGL中的鼠标按钮释放 [英] Determine mouse button release in LWJGL
问题描述
我在LWJGL中有一个程序,其中有一系列按钮.我正在尝试使用Mouse.getEventButton()
和Mouse.getEventButtonState()
来确定何时释放鼠标,但似乎都无法正常工作.在添加了一些用于调试的打印语句之后,看来getEventButton()
总是返回0,无论鼠标在做什么,而getEventButtonState()
总是返回false.到目前为止,我使用的所有其他鼠标方法都表现正常.知道会发生什么吗?
I have a program in LWJGL where I have a series of buttons. I'm trying to use Mouse.getEventButton()
and Mouse.getEventButtonState()
in order to figure out when the mouse is released, but neither seem to be working. After adding a few print statements for debugging, it seems that getEventButton()
always returns 0 regardless of what the mouse is doing, and getEventButtonState()
always returns false. All other mouse methods I've used so far have behaved normally. Any idea what might be going on?
推荐答案
可以用类比键盘来完成,如中所述教程.
It can be done by analogy with keyboard as described in this tutorial.
while (Mouse.next()){
if (Mouse.getEventButtonState()) {
if (Mouse.getEventButton() == 0) {
System.out.println("Left button pressed");
}
}else {
if (Mouse.getEventButton() == 0) {
System.out.println("Left button released");
}
}
}
这篇关于确定LWJGL中的鼠标按钮释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!