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 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,10 +252,15 @@ 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;
}
xVelocity *= 0.93;