#monogame #library #input #gamedev
|
1 năm trước cách đây | |
---|---|---|
.github | 1 năm trước cách đây | |
Images | 6 năm trước cách đây | |
Source | 3 năm trước cách đây | |
docs | 1 năm trước cách đây | |
.gitignore | 4 năm trước cách đây | |
CHANGELOG.md | 1 năm trước cách đây | |
LICENSE | 6 năm trước cách đây | |
README.md | 1 năm trước cách đây |
Polling input library for MonoGame.
In your game's LoadContent()
, pass the game class to InputHelper.Setup()
:
protected override void LoadContent() {
InputHelper.Setup(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 jump.
// It should work on space, the first gamepad's A button, or the mouse's left button.
ICondition jump =
new AnyCondition(
new KeyboardCondition(Keys.Space),
new GamePadCondition(GamePadButton.A, 0),
new MouseCondition(MouseButton.LeftButton)
);
// To check if the jump is triggered:
if (jump.Pressed()) {
// Do the jump change.
}