ajout de l'option pour désactiver la musique (son non fonctionnel
This commit is contained in:
parent
92e714411c
commit
ae2ab5b643
BIN
core/assets/sounds/fleche_decochee.mp3
Normal file
BIN
core/assets/sounds/fleche_decochee.mp3
Normal file
Binary file not shown.
|
@ -12,6 +12,8 @@ public class SagittariusGame extends Game {
|
||||||
public static float G = 100;
|
public static float G = 100;
|
||||||
public static boolean debugMode = true;
|
public static boolean debugMode = true;
|
||||||
public static Music music;
|
public static Music music;
|
||||||
|
public static boolean disableSounds = false;
|
||||||
|
public static float soundsVolume = 0.5f;
|
||||||
private static Game game;
|
private static Game game;
|
||||||
|
|
||||||
public SagittariusGame() {
|
public SagittariusGame() {
|
||||||
|
@ -31,6 +33,7 @@ public class SagittariusGame extends Game {
|
||||||
|
|
||||||
// A welcome music is played
|
// A welcome music is played
|
||||||
music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3"));
|
music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3"));
|
||||||
|
music.setLooping(true);
|
||||||
music.play();
|
music.play();
|
||||||
|
|
||||||
// Default volume
|
// Default volume
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.badlogic.gdx.audio.Sound;
|
||||||
import com.badlogic.gdx.files.*;
|
import com.badlogic.gdx.files.*;
|
||||||
|
|
||||||
import sagittarius.view.GameScreen;
|
import sagittarius.view.GameScreen;
|
||||||
|
import sagittarius.SagittariusGame;
|
||||||
|
|
||||||
public class Bow extends Actor {
|
public class Bow extends Actor {
|
||||||
|
|
||||||
|
@ -50,7 +51,12 @@ public class Bow extends Actor {
|
||||||
Arrow arrowShot = new Arrow(angle, power, GameScreen.playerCurrent, false);
|
Arrow arrowShot = new Arrow(angle, power, GameScreen.playerCurrent, false);
|
||||||
GameScreen.setFocus(arrowShot); // do not use constructor 2 times
|
GameScreen.setFocus(arrowShot); // do not use constructor 2 times
|
||||||
GameScreen.arrows.addActor(arrowShot);
|
GameScreen.arrows.addActor(arrowShot);
|
||||||
shotSound.play();
|
|
||||||
|
// Make a sound when an arrow is shot
|
||||||
|
if ( ! SagittariusGame.disableSounds){
|
||||||
|
long shotid = shotSound.play(SagittariusGame.soundsVolume);
|
||||||
|
shotSound.setPitch(shotid,1.5f);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
pressed = false;
|
pressed = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,10 +33,18 @@ public class SettingsScreen extends BaseScreen {
|
||||||
debugModeBox.setChecked(SagittariusGame.debugMode);
|
debugModeBox.setChecked(SagittariusGame.debugMode);
|
||||||
|
|
||||||
|
|
||||||
|
// disable music checkbox
|
||||||
|
VisCheckBox disableMusic = new VisCheckBox("disable music");
|
||||||
|
|
||||||
// Change volume of the music
|
// Change volume of the music
|
||||||
Spinner musicVolume= new Spinner("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
|
Spinner musicVolume= new Spinner("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
|
||||||
|
|
||||||
|
// disable sound checkbox
|
||||||
|
VisCheckBox disableSounds= new VisCheckBox("disable sounds");
|
||||||
|
disableSounds.setChecked(SagittariusGame.disableSounds);
|
||||||
|
|
||||||
|
// Change volume of the sound
|
||||||
|
Spinner musicSounds= new Spinner("Sounds Volume:", new SimpleFloatSpinnerModel(SagittariusGame.soundsVolume, 0f, 1.0f, 0.01f, 3));
|
||||||
|
|
||||||
// save button
|
// save button
|
||||||
VisTextButton saveButton = new VisTextButton("Save");
|
VisTextButton saveButton = new VisTextButton("Save");
|
||||||
|
@ -47,8 +55,10 @@ public class SettingsScreen extends BaseScreen {
|
||||||
|
|
||||||
SagittariusGame.G = Float.parseFloat(gConstField.getTextField().getText());
|
SagittariusGame.G = Float.parseFloat(gConstField.getTextField().getText());
|
||||||
SagittariusGame.music.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
|
SagittariusGame.music.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
|
||||||
|
SagittariusGame.soundsVolume = Float.parseFloat(musicVolume.getTextField().getText());
|
||||||
SagittariusGame.debugMode = debugModeBox.isChecked();
|
SagittariusGame.debugMode = debugModeBox.isChecked();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,8 +75,14 @@ public class SettingsScreen extends BaseScreen {
|
||||||
// Table structure
|
// Table structure
|
||||||
table.add(gConstField).width(250);
|
table.add(gConstField).width(250);
|
||||||
table.row();
|
table.row();
|
||||||
|
table.add(disableMusic).width(250);
|
||||||
|
table.row();
|
||||||
table.add(musicVolume).width(250);
|
table.add(musicVolume).width(250);
|
||||||
table.row();
|
table.row();
|
||||||
|
table.add(disableSounds).width(250);
|
||||||
|
table.row();
|
||||||
|
table.add(musicSounds).width(250);
|
||||||
|
table.row();
|
||||||
table.add(debugModeBox).align(Align.left);
|
table.add(debugModeBox).align(Align.left);
|
||||||
table.row();
|
table.row();
|
||||||
table.add(saveButton).width(250);
|
table.add(saveButton).width(250);
|
||||||
|
|
Loading…
Reference in a new issue