我一直在拍攝Em Up遊戲一段時間的問題,我真的無法找到任何答案。即使我按住空格鍵,我也只想拍1發子彈。用我目前的代碼,我根本不會發射任何子彈。我究竟做錯了什麼?C# - 僅拍攝一次 - IsKeyUp&IsKeyDown
KeyboardState newState = Keyboard.GetState();
KeyboardState oldState = Keyboard.GetState();
if (oldState.IsKeyUp(Keys.Space) && newState.IsKeyDown(Keys.Space))
{
bulletList.Add(new Bullet(content.Load<Texture2D>(@"bullet"), new Vector2(initialPos.X, initialPos.Y - 28), new Vector2(2, 4), spriteBatch));
}
oldState = newState;
[這裏是示例](http://msdn.microsoft.com/en-us/library/bb203902.aspx) –