I\'ve begun writing a game using XNA Framework and have hit some simple problem I do not know how to solve correctly.
I\'m displaying a menu using Texture2D and using th
Ok, I've figured it out. First, I added a
private Keys keyPressed = Keys.None;
and in my Update() method, I do the following:
KeyboardState keyboardState = Keyboard.GetState();
if (keyboardState.IsKeyUp(keyPressed))
{
keyPressed = Keys.None;
}
if (keyboardState.IsKeyDown(keyPressed))
{
return;
}
// Some additionnal stuff is done according to direction
if (keyboardState.IsKeyDown(Keys.Up))
{
keyPressed = Keys.Up;
}
else if (keyboardState.IsKeyDown(Keys.Down))
{
keyPressed = Keys.Down;
}
It seems to be working correctly.