1
基本上,當我嘗試創建OpenFileDialog時,通過單擊「遊戲」中的特定區域,我的mouseState即使已釋放,仍保持「按下」狀態。OpenFileDialog破壞mouseState
OpenFileDialog dialog;
protected override void Update(GameTime gameTime)
{
if (selectSong.isClicked)
{
DialogResult result = dialog.ShowDialog();
if (result == DialogResult.OK)
{
//code;
}
else
{
selectSong.isClicked = false;
// Disabling mouse event - because isClicked is always true after using showDialog()
}
}
UpdateMouse();
}
protected void UpdateMouse()
{
MouseState current_mouse = Mouse.GetState();
Console.Clear();
int mouseX = current_mouse.X;
int mouseY = current_mouse.Y;
selectSong.checkCollision(mouseX, mouseY, current_mouse.LeftButton);
exit.checkCollision(mouseX, mouseY, current_mouse.LeftButton);
Console.WriteLine("mouse X:" + mouseX + " mouse Y:" + mouseY);
Console.WriteLine("Left button down:" + current_mouse.LeftButton.ToString());
// Left button down - after creating Dialog.ShowDialog() is always pressed, even after releasing mouse, and hitting cancel in Dialog
}
這裏描述問題http://db.tt/NVnEUgLI
是'UpdateMouse('是文件對話框打開後調用? (添加一個斷點) – Cyral
當然,在.showDialog()上添加斷點後,並在我的updatemouse()函數中添加斷點 - 它會不斷更新,每次都是 - 每次左鍵都被按下 - 即使它被釋放了。 –
嘗試使用Mouse.GetState()。LeftButton.ToString()來測試您是否正確更新current_mouse? –