Game Development Reference
In-Depth Information
Now, let's connect the audio manager with the Options menu in the menu screen
and the rest of the game.
Add the following import line to MenuScreen :
import com.packtpub.libgdx.canyonbunny.util.AudioManager;
Next, make the following changes to the same class:
private void onSaveClicked () {
saveSettings();
onCancelClicked();
AudioManager.instance.onSettingsUpdated();
}
private void onCancelClicked () {
btnMenuPlay.setVisible(true);
btnMenuOptions.setVisible(true);
winOptions.setVisible(false);
AudioManager.instance.onSettingsUpdated();
}
These changes make sure that when the Options menu is closed, the audio manager
will start or stop the music depending on the current audio settings.
Next, add the following import lines to the CanyonBunnyMain class:
import com.packtpub.libgdx.canyonbunny.util.AudioManager;
import com.packtpub.libgdx.canyonbunny.util.GamePreferences;
After this, make the following changes to the same class:
@Override
public void create () {
// Set Libgdx log level
Gdx.app.setLogLevel(Application.LOG_DEBUG);
// Load assets
Assets.instance.init(new AssetManager());
// Load preferences for audio settings and start playing music
GamePreferences.instance.load();
AudioManager.instance.play(Assets.instance.music.song01);
// Start game at menu screen
 
Search WWH ::




Custom Search