I am making a game but having exported it, I found that my sounds stop my game. The thread pauses. Here is what I'm doing in my key listener class:
//creating a bullet
handler.addObject(new PlayerShot1(tempObject.getX() + 58, tempObject.getY(), Id.PlayerShot1));
//changing variable to play sound
Player.shooting = true;
And in my Player class:
//called every time the spacebar is pressed
if(shooting) {
GetAudio.getSound("playerShot1").play(2.0f, 0.1f);
shooting = false;
}
I have commented out the GetAudio.... line and it started working again. Just in case, here is my GetAudio class:
public class GetAudio {
public static Map<String, Sound> soundMap = new HashMap<String, Sound>();
public static Map<String, Music> musicMap = new HashMap<String, Music>();
public static void get() {
try {
soundMap.put("playerShot1", new Sound("./resources/sounds/playerShot1.ogg"));
} catch (SlickException e) {
e.printStackTrace();
}
}
public static Music getMusic(String key) {
return musicMap.get(key);
}
public static Sound getSound(String key) {
return soundMap.get(key);
}
}
Thanks in advance for your help!