ButtonDown
Introduction
The ButtonDown method returns whether a button is currently being held down. This will be false if the player is not pushing the button, and it will return true every frame that the button is pressed.
Code Example - Checking Buttons
The following code shows how to perform logic if the player is holding the A or B buttons on the Xbox360GamePad:
Add the following using statements:
Later, perform the checks:
Code Example - Checking DPad
The DPad on the Xbox360GamePad acts as four separate buttons. Therefore, each direction can be independently checked just like buttons. For example, the following code moves a character according to the left and right DPad.
Code Example - Checking All Buttons
Buttons are represented by enumerations which can be looped through to check. The first enumeration value is 0, and the last value in the enumeration is Button.LeftStickAsDPadRight. Therefore, the following loop will check all buttons:
Last updated