Skip to content
Snippets Groups Projects
Commit 5fb17d69 authored by Haakon Gunleiksrud's avatar Haakon Gunleiksrud
Browse files

#32 Added functionality for toggling sound effects.

parent 8f230e1d
Branches
No related tags found
1 merge request!26Resolve "Options-functionality"
...@@ -18,6 +18,7 @@ public class GameWare extends ApplicationAdapter { ...@@ -18,6 +18,7 @@ public class GameWare extends ApplicationAdapter {
public static final String skinFilePath = "glassy/skin/glassy-ui.json"; public static final String skinFilePath = "glassy/skin/glassy-ui.json";
private static Music music; private static Music music;
private static Boolean musicOn = false; private static Boolean musicOn = false;
private static Boolean soundEffects = true;
private static GameWare instance = null; private static GameWare instance = null;
//Singleton (lazy initialization) //Singleton (lazy initialization)
...@@ -53,6 +54,13 @@ public class GameWare extends ApplicationAdapter { ...@@ -53,6 +54,13 @@ public class GameWare extends ApplicationAdapter {
musicOn = !musicOn; musicOn = !musicOn;
} }
public static void toggleSoundEffects(){
soundEffects = !soundEffects;
}
public static Boolean getSoundEffects() {
return soundEffects;
}
@Override @Override
public void dispose () { public void dispose () {
......
...@@ -45,21 +45,22 @@ public class OptionsState extends State { ...@@ -45,21 +45,22 @@ public class OptionsState extends State {
public void clicked(InputEvent e, float x, float y){ GameWare.toggleMusic(); } public void clicked(InputEvent e, float x, float y){ GameWare.toggleMusic(); }
}); });
Label musicToggleLabel = new Label(musicToggleLabelText,skin); Label musicToggleLabel = new Label(musicToggleLabelText,skin);
table.add(musicToggleLabel); table.add(musicToggleLabel);
table.add(musicToggle); table.add(musicToggle);
table.row(); table.row();
CheckBox soundEffectToggle = new CheckBox("",skin); CheckBox soundEffectToggle = new CheckBox("",skin);
soundEffectToggle.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ GameWare.toggleSoundEffects(); }
});
Label soundEffectToggleLabel = new Label(soundEffectToggleLabelText,skin); Label soundEffectToggleLabel = new Label(soundEffectToggleLabelText,skin);
table.add(soundEffectToggleLabel); table.add(soundEffectToggleLabel);
table.add(soundEffectToggle); table.add(soundEffectToggle);
table.row(); table.row();
CheckBox darkModeToggle = new CheckBox("",skin); CheckBox darkModeToggle = new CheckBox("",skin);
Label darkModeToggleLabel = new Label(darkModeToggleLabelText,skin); Label darkModeToggleLabel = new Label(darkModeToggleLabelText,skin);
table.add(darkModeToggleLabel); table.add(darkModeToggleLabel);
table.add(darkModeToggle); table.add(darkModeToggle);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment