1
public void get_Mouse_press()
{
boolean leftDown = Mouse.isButtonDown(0);
boolean rightDown = Mouse.isButtonDown(1);
validate_Mouse_press(leftDown, rightDown);
}
public void validate_Mouse_press(boolean left, boolean right)
{
if (left == true)
{
if(repeatLeftPressed == false)
{
System.out.println("Left mouse button down");
repeatLeftPressed = true;
repeatLeftReleased = false;
}
if(repeatLeftPressed == true)
{
repeatLeftReleased = false;
}
}
if (right == true)
{
if(repeatRightPressed == false)
{
System.out.println("Right mouse button down");
repeatRightPressed = true;
repeatRightReleased = false;
}
if(repeatRightPressed == true)
{
repeatRightReleased = false;
}
}
if (left == false)
{
if(repeatLeftReleased = false)
{
System.out.println("Left mouse button released");
repeatLeftReleased = true;
repeatLeftPressed = false;
}
if(repeatLeftReleased == true)
{
repeatLeftPressed = false;
}
}
if (right == false)
{
if(repeatRightReleased = false)
{
System.out.println("Right mouse button released");
repeatRightReleased = true;
repeatRightPressed = false;
}
if(repeatRightReleased == true)
{
repeatRightPressed = false;
}
}
}
當我運行我的程序時,它無法正常工作。我希望程序每次按下鼠標鍵,每次釋放鼠標鍵時,都會在屏幕上打印相應的語句。這是爲了防止快速fps的洪水。 但是,它僅在第一次單擊左鍵或右鍵時顯示。鼠標聽衆防洪只報告第一次點擊
輸出是
"Left mouse button down"
"Right mouse button down"
上述輸出是所有顯示,儘管許多點擊。我不確定我做錯了什麼。我不知道如何避免在輪詢鼠標按鈕狀態時阻止控制檯氾濫,而無需進行某種控制檯打印控制。有沒有更有效的方法來做到這一點?或者這是足夠的,只有一些被忽視的錯誤?
我已閱讀它。多次,錯誤在哪裏? – 2014-08-30 07:03:35
啊,比較語句中的賦值語句。錯誤的操作員。我剛剛發現了這一點。 – 2014-08-30 07:21:05