C# Класс TraceRacer.InputState

Helper for reading input from keyboard, gamepad, and touch input. This class tracks both the current and previous state of the input devices, and implements query methods for high level input actions such as "move up through the menu" or "pause the game".
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
CurrentGamePadStates Microsoft.Xna.Framework.Input.GamePadState[]
CurrentKeyboardStates Microsoft.Xna.Framework.Input.KeyboardState[]
GamePadWasConnected bool[]
Gestures List
LastGamePadStates Microsoft.Xna.Framework.Input.GamePadState[]
LastKeyboardStates Microsoft.Xna.Framework.Input.KeyboardState[]
TouchState TouchCollection

Открытые методы

Метод Описание
InputState ( ) : System.Collections.Generic

Constructs a new input state.

IsButtonPressed ( Buttons button, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool

Helper for checking if a button was pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a button press is detected, the output playerIndex reports which player pressed it.

IsKeyPressed ( Keys key, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool

Helper for checking if a key was pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a keypress is detected, the output playerIndex reports which player pressed it.

IsNewButtonPress ( Buttons button, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool

Helper for checking if a button was newly pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a button press is detected, the output playerIndex reports which player pressed it.

IsNewKeyPress ( Keys key, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool

Helper for checking if a key was newly pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a keypress is detected, the output playerIndex reports which player pressed it.

Update ( ) : void

Reads the latest state user input.

Описание методов

InputState() публичный Метод

Constructs a new input state.
public InputState ( ) : System.Collections.Generic
Результат System.Collections.Generic

IsButtonPressed() публичный Метод

Helper for checking if a button was pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a button press is detected, the output playerIndex reports which player pressed it.
public IsButtonPressed ( Buttons button, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool
button Buttons
controllingPlayer PlayerIndex
playerIndex PlayerIndex
Результат bool

IsKeyPressed() публичный Метод

Helper for checking if a key was pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a keypress is detected, the output playerIndex reports which player pressed it.
public IsKeyPressed ( Keys key, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool
key Keys
controllingPlayer PlayerIndex
playerIndex PlayerIndex
Результат bool

IsNewButtonPress() публичный Метод

Helper for checking if a button was newly pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a button press is detected, the output playerIndex reports which player pressed it.
public IsNewButtonPress ( Buttons button, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool
button Buttons
controllingPlayer PlayerIndex
playerIndex PlayerIndex
Результат bool

IsNewKeyPress() публичный Метод

Helper for checking if a key was newly pressed during this update. The controllingPlayer parameter specifies which player to read input for. If this is null, it will accept input from any player. When a keypress is detected, the output playerIndex reports which player pressed it.
public IsNewKeyPress ( Keys key, PlayerIndex controllingPlayer, PlayerIndex &playerIndex ) : bool
key Keys
controllingPlayer PlayerIndex
playerIndex PlayerIndex
Результат bool

Update() публичный Метод

Reads the latest state user input.
public Update ( ) : void
Результат void

Описание свойств

CurrentGamePadStates публичное свойство

public GamePadState[],Microsoft.Xna.Framework.Input CurrentGamePadStates
Результат Microsoft.Xna.Framework.Input.GamePadState[]

CurrentKeyboardStates публичное свойство

public KeyboardState[],Microsoft.Xna.Framework.Input CurrentKeyboardStates
Результат Microsoft.Xna.Framework.Input.KeyboardState[]

GamePadWasConnected публичное свойство

public bool[] GamePadWasConnected
Результат bool[]

Gestures публичное свойство

public List Gestures
Результат List

LastGamePadStates публичное свойство

public GamePadState[],Microsoft.Xna.Framework.Input LastGamePadStates
Результат Microsoft.Xna.Framework.Input.GamePadState[]

LastKeyboardStates публичное свойство

public KeyboardState[],Microsoft.Xna.Framework.Input LastKeyboardStates
Результат Microsoft.Xna.Framework.Input.KeyboardState[]

TouchState публичное свойство

public TouchCollection TouchState
Результат TouchCollection