#monogame #library #input #gamedev
|
6 年之前 | |
---|---|---|
Images | 6 年之前 | |
Source | 6 年之前 | |
docs | 6 年之前 | |
.gitignore | 6 年之前 | |
LICENSE | 6 年之前 | |
README.md | 6 年之前 |
Input library for MonoGame.
In your game's Initialize()
, pass the game class to InputHelper.Game:
protected override void Initialize() {
InputHelper.Game = this;
}
In your game's Update(GameTime gameTime)
, call the two functions:
protected override void Update(GameTime gametime) {
//Call UpdateSetup at the start.
InputHelper.UpdateSetup();
//...
//Call UpdateCleanup at the end.
InputHelper.UpdateCleanup();
}
//Create a condition to toggle fullscreen.
//It should work on both Alt keys and Enter.
var toggleFullScreen = new ConditionComposite();
toggleFullscreen.AddSet(Keys.Enter).AddNeed(Keys.LeftAlt);
toggleFullscreen.AddSet(Keys.Enter).AddNeed(Keys.RightAlt);
//To check if toggleFullscreen is triggered:
if (toggleFullscreen.Pressed()) {
//Do the fullscreen change.
}