Hi today I bring an issue that I watched last week about keyboard input in XNA.
It is an interesting topic, I like it to much, but it was a little complicated.
I use an example from learining XNA Book.
Keyboard input is handled via the Keyboard class, Which Is In The Microsoft.XNA.
Framework.Input namespace.
Add these class-level variables at the top of your class:
Vector2 ringsPosition = Vector2.Zero;
const float ringsSpeed = 6;
So, go ahead and add the following code to the end of your Update method, just before the call to base.Update:
KeyboardState keyboardState = Keyboard.GetState ();
if (keyboardState.IsKeyDown (Keys.Left))
ringsPosition.X -= ringsSpeed;
if (keyboardState.IsKeyDown (Keys.Right))
ringsPosition.X + = ringsSpeed;
if (keyboardState.IsKeyDown (Keys.Up))
ringsPosition.Y -= ringsSpeed;
if (keyboardState.IsKeyDown (Keys.Down))
ringsPosition.Y + = ringsSpeed;
Regards
