I want background music to be played over various screens of my game the music is initially started in the first screen class:
boolean backgroundMusicPlaying = backgroundMusic.isPlaying();
public MainMenuScreen(Game1 gam){
(...)
if(backgroundMusicPlaying != true){
backgroundMusic.play();
backgroundMusic.setVolume(0.3f);
backgroundMusic.setLooping(true);
backgroundMusicPlaying = true;
}
(...)
}
Problem
The problem is when i return to this class after I have been to a previous screen in the game it restarts the music but i don't want this i want it to be a continuous loop.
An example of how the screen's are changed to and from this class/screen:
game.setScreen(new playOptions(game));