Fix sound bug on game resume

master
John 2022-06-18 22:27:44 -04:00
parent 5ae603cb06
commit 3359ab9ff1
1 changed files with 8 additions and 3 deletions

View File

@ -24,7 +24,7 @@ public class Player extends GenericSprite {
public static final int walkSpeedCap = 5; public static final int walkSpeedCap = 5;
public boolean alive; 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 mouseX;
public static int mouseY; public static int mouseY;
@ -252,10 +252,15 @@ public class Player extends GenericSprite {
y-=1; y-=1;
isGrounded = false; isGrounded = false;
if(canUpdate(0,-8)) { if(canUpdate(0,-8)) {
if (jump != null) { if (jump == null) {
jump.start(); try {
jump = new Sound("sound/jump.wav");
} catch (UnsupportedAudioFileException | LineUnavailableException e) {
throw new RuntimeException(e);
} }
} }
jump.start();
}
yVelocity = -10; yVelocity = -10;
} }
xVelocity *= 0.93; xVelocity *= 0.93;