0
爲了從MouseState獲得單擊響應,我使用這一行。XNA:mouseState的位置是否重要?
currentMouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released)
而在該方法的末尾,我有這條線設置鼠標狀態。
oldMouseState = currentMouseState;
我給你的問題是上面的行的位置在一個有多個循環的方法中的位置嗎?是這樣的:
foreach (blah blah in blahs)
{
if (something is something)
{
if (currentMouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released)
{
do something
}
}
}oldMouseState = currentMouseState;
與此不同嗎?
foreach (blah blah in blahs)
{
if (something is something)
{
if (currentMouseState.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Released)
{
do something
}
}oldMouseState = currentMouseState;
}
當然你可以通過簡單地運行你的代碼來調查你的問題的結果。對我來說似乎很明顯 – MickyD 2014-10-18 05:19:40