Input
The MonoGame.Extended.Input
provides extensions on top of the normal input classes.
Installation
MonoGame.Extended.Input is distributed via a NuGet package. You can add the NuGet package to your C# project through your IDE of choice (Visual Studio, Xamarin Studio, Rider, etc) or through the Command Line Interface (CLI) using the dotnet command.
Usage
MouseExtended
MouseExtended
is an extension of the Mouse
class. The MouseStateExtended
struct, obtained with MouseExtended.GetState()
provides useful utilities such as WasButtonJustDown()
and WasButtonJustUp()
by keeping track of the previous MouseState
.
KeyboardExtended
KeyboardExtended
is an extension of the Keyboard
class. The KeyboardStateExtended
struct, obtained with KeyboardExtended.GetState()
provides useful utilities such as WasAnyKeyJustDown()
, WasKeyJustDown()
and WasKeyJustUp()
by keeping track of the previous KeyboardState
.
InputListeners
Listener
classes have events you can use to subscribe to input events, instead of having to poll for input changes.
Usage
We start by including the required namespace.
Next, we declare our InputListener
fields
You can manually call the Update
method of the Listeners
, but you can also use InputListenerComponent
this this.
Finaly, we subscribe to the events of the InputListeners