Summary
• Input devices supported in XNA include the keyboard, mouse, and Xbox 360
controller.
• The Xbox 360 has several analog inputs that allow for varying degrees of input
from a single button.
• Input devices supported in XNA include the keyboard, mouse, and Xbox 360
controller.
• The Xbox 360 has several analog inputs that allow for varying degrees of input
from a single button.
- Code:
//Update time since last frame and only
//MOUSE INPUT
MouseState ms = Mouse.GetState();
if (ms.LeftButton == ButtonState.Pressed)
ringpos = new Vector2(ms.X, ms.Y);
//KEYBOARD INPUT
KeyboardState ks = Keyboard.GetState();
if (ks.IsKeyDown(Keys.Z))
ringpos.Y += speed.Y;
if (ks.IsKeyDown(Keys.S))
ringpos.Y -= speed.Y;
if (ks.IsKeyDown(Keys.Q))
ringpos.X -= speed.X;
if (ks.IsKeyDown(Keys.D))
ringpos.X += speed.X;