Skip to content

Commit 89f5f94

Browse files
authored
Use WasKeyJustPressed for ExitOnEscape (#120)
* Use WasKeyJustPressed for ExitOnEscape * Fix typo * Use keyboard like other keys
1 parent e377a95 commit 89f5f94

7 files changed

Lines changed: 8 additions & 8 deletions

File tree

  • Tutorials/learn-monogame-2d/src
    • 11-Input-Management/MonoGameLibrary
    • 12-Collision-Detection/MonoGameLibrary
    • 13-Tilemap/MonoGameLibrary
    • 14-SoundEffects-And-Music/MonoGameLibrary
    • 15-Audio-Controller/MonoGameLibrary
    • 16-Working-With-SpriteFonts/MonoGameLibrary
    • 17-Scenes/DungeonSlime/Scenes

Tutorials/learn-monogame-2d/src/11-Input-Management/MonoGameLibrary/Core.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected override void Update(GameTime gameTime)
112112
// Update the input manager
113113
Input.Update(gameTime);
114114

115-
if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape))
115+
if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape))
116116
{
117117
Exit();
118118
}

Tutorials/learn-monogame-2d/src/12-Collision-Detection/MonoGameLibrary/Core.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected override void Update(GameTime gameTime)
112112
// Update the input manager
113113
Input.Update(gameTime);
114114

115-
if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape))
115+
if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape))
116116
{
117117
Exit();
118118
}

Tutorials/learn-monogame-2d/src/13-Tilemap/MonoGameLibrary/Core.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected override void Update(GameTime gameTime)
112112
// Update the input manager
113113
Input.Update(gameTime);
114114

115-
if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape))
115+
if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape))
116116
{
117117
Exit();
118118
}

Tutorials/learn-monogame-2d/src/14-SoundEffects-And-Music/MonoGameLibrary/Core.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ protected override void Update(GameTime gameTime)
112112
// Update the input manager
113113
Input.Update(gameTime);
114114

115-
if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape))
115+
if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape))
116116
{
117117
Exit();
118118
}

Tutorials/learn-monogame-2d/src/15-Audio-Controller/MonoGameLibrary/Core.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected override void Update(GameTime gameTime)
132132
// Update the audio controller.
133133
Audio.Update();
134134

135-
if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape))
135+
if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape))
136136
{
137137
Exit();
138138
}

Tutorials/learn-monogame-2d/src/16-Working-With-SpriteFonts/MonoGameLibrary/Core.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ protected override void Update(GameTime gameTime)
132132
// Update the audio controller.
133133
Audio.Update();
134134

135-
if (ExitOnEscape && Input.Keyboard.IsKeyDown(Keys.Escape))
135+
if (ExitOnEscape && Input.Keyboard.WasKeyJustPressed(Keys.Escape))
136136
{
137137
Exit();
138138
}

Tutorials/learn-monogame-2d/src/17-Scenes/DungeonSlime/Scenes/GameScene.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,11 @@ private void AssignRandomBatVelocity()
249249

250250
private void CheckKeyboardInput()
251251
{
252-
// Get a reference to the keyboard inof
252+
// Get a reference to the keyboard info
253253
KeyboardInfo keyboard = Core.Input.Keyboard;
254254

255255
// If the escape key is pressed, return to the title screen
256-
if (Core.Input.Keyboard.WasKeyJustPressed(Keys.Escape))
256+
if (keyboard.WasKeyJustPressed(Keys.Escape))
257257
{
258258
Core.ChangeScene(new TitleScene());
259259
}

0 commit comments

Comments
 (0)