FlatRedBall.Input.I2DInput

Introduction

The I2DInput interface can be used to generalize input code for detecting a value and velocity along two dimensions (X and Y). A common usage of this is to control an object’s 2-dimensional movement such as a character in a top-down game. Numerous common input devices are implemented as I1DInput.

The X and Y properties typically return values between -1 and 1.

Code Example

The following shows how to move an entity horizontally and vertically using I2DInput. It assumes that the code has an Entity called Character.

In Character.cs:

In the Screen’s CustomInitialize, assuming it has a CharacterInstance:

Common Usage

The following shows how to use the most common FRB input classes to gt I1DInput:

Keyboard

Xbox360GamePad DPad

Xbox360GamePad AnalogStick