0
我有一個遊戲,點擊一個按鈕,它將一個整數增加一個,但是,使用當前代碼,用戶可以按住鼠標不斷增加。檢測鼠標點擊
我怎樣才能讓用戶只能按一次(每次點擊)來增加他們的分數?
下面是當前的代碼,我有:
public MouseState mouseState;
protected override void Update(GameTime gameTime)
{
mouseState = Mouse.GetState();
if (mouseState.LeftButton == ButtonState.Pressed)
Managers.UserManager.OverallScore++;
base.Update(gameTime);
}
嗨,感謝您的建議!我嘗試了代碼,但是,即使按鈕未按下,值也會持續增加。 – Jarrod
刷新頁面,我有一個錯誤! – radical
謝謝你的幫助!完美的答案 – Jarrod