public IsButtonDown ( Buttons button ) : bool | ||
button | Buttons | |
return | bool |
GamePadState state = GamePad.GetState(PlayerIndex.One); if (state.IsButtonDown(Buttons.A)) { // A button is being pressed }
bool isButtonDown = GamePad.GetState(PlayerIndex.One).IsButtonDown(Buttons.B);This example uses the method to directly determine whether the B button on Player One's gamepad is currently being pressed, and assigns the result to a boolean variable. The package library for Microsoft.Xna.Framework.Input is Microsoft.Xna.Framework.