错误:Microsoft.Xna.Framework.Input.KeyState'不包含' GetPressedKeys'的定义

时间:2014-10-24 15:19:16

标签: c# xna

全部。我想用C#和XNA编写一个输入文本框。这是我的代码:

//Get the pressed key and show them
 public void Update(GameTime gameTime)
      {
            KeyboardState keyState = Keyboard.GetState();
            Keys[] pressedKeys;
            pressedKeys = KeyState.GetPressedKeys();

            messageString=" ";

            for (int i = 0; i < pressedKeys.Length; i++)
                messageString = messageString + pressedKeys[i].ToString() + "";

      }

但是,我收到了类似

的错误消息
Microsoft.Xna.Framework.Input.KeyState' does not contain a definition for 'GetPressedKeys'

有什么办法可以解决吗?

更新:我在这里打字错误。使用以下答案可以解决问题。

1 个答案:

答案 0 :(得分:0)

pressedKeys = KeyState.GetPressedKeys();应该是pressKeys = keyState.GetPressedKeys();