全部。我想用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'
有什么办法可以解决吗?
更新:我在这里打字错误。使用以下答案可以解决问题。
答案 0 :(得分:0)
pressedKeys = KeyState.GetPressedKeys();应该是pressKeys = keyState.GetPressedKeys();