From 3359ab9ff1850251dd43c4cf515fffa7024e786f Mon Sep 17 00:00:00 2001 From: John Date: Sat, 18 Jun 2022 22:27:44 -0400 Subject: [PATCH] Fix sound bug on game resume --- src/Player.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Player.java b/src/Player.java index af1e117..aabb64c 100644 --- a/src/Player.java +++ b/src/Player.java @@ -24,7 +24,7 @@ public class Player extends GenericSprite { public static final int walkSpeedCap = 5; public boolean alive; - private transient final Sound jump = new Sound("sound/jump.wav"); + private transient Sound jump = new Sound("sound/jump.wav"); public static int mouseX; public static int mouseY; @@ -252,9 +252,14 @@ public class Player extends GenericSprite { y-=1; isGrounded = false; if(canUpdate(0,-8)) { - if (jump != null) { - jump.start(); + if (jump == null) { + try { + jump = new Sound("sound/jump.wav"); + } catch (UnsupportedAudioFileException | LineUnavailableException e) { + throw new RuntimeException(e); + } } + jump.start(); } yVelocity = -10; }