1 musique par menu et une pour la game
This commit is contained in:
parent
ae2ab5b643
commit
037bbc7ce1
BIN
core/assets/sounds/HMO-MercuryCity.mp3
Normal file
BIN
core/assets/sounds/HMO-MercuryCity.mp3
Normal file
Binary file not shown.
BIN
core/assets/sounds/Metre - Concentric.mp3
Normal file
BIN
core/assets/sounds/Metre - Concentric.mp3
Normal file
Binary file not shown.
BIN
core/assets/sounds/bensound-house.mp3
Normal file
BIN
core/assets/sounds/bensound-house.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 disableMusic= false;
|
||||||
|
public static float musicVolume= 0.5f;
|
||||||
public static boolean disableSounds = false;
|
public static boolean disableSounds = false;
|
||||||
public static float soundsVolume = 0.5f;
|
public static float soundsVolume = 0.5f;
|
||||||
private static Game game;
|
private static Game game;
|
||||||
|
@ -31,14 +33,6 @@ public class SagittariusGame extends Game {
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
||||||
|
|
||||||
// A welcome music is played
|
|
||||||
music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3"));
|
|
||||||
music.setLooping(true);
|
|
||||||
music.play();
|
|
||||||
|
|
||||||
// Default volume
|
|
||||||
music.setVolume(0.3f);
|
|
||||||
|
|
||||||
// We load the VisUI library
|
// We load the VisUI library
|
||||||
VisUI.load();
|
VisUI.load();
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.graphics.GL30;
|
import com.badlogic.gdx.graphics.GL30;
|
||||||
import com.badlogic.gdx.scenes.scene2d.Stage;
|
import com.badlogic.gdx.scenes.scene2d.Stage;
|
||||||
|
|
||||||
|
import sagittarius.SagittariusGame;
|
||||||
|
|
||||||
import com.badlogic.gdx.Screen;
|
import com.badlogic.gdx.Screen;
|
||||||
|
|
||||||
public abstract class BaseScreen implements Screen {
|
public abstract class BaseScreen implements Screen {
|
||||||
|
@ -42,6 +44,8 @@ public abstract class BaseScreen implements Screen {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void dispose() {
|
@Override public void dispose() {
|
||||||
|
|
||||||
|
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3"));
|
||||||
uiStage.dispose();
|
uiStage.dispose();
|
||||||
mainStage.dispose();
|
mainStage.dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,13 @@ public class GameScreen extends BaseScreen implements InputProcessor {
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
|
if (SagittariusGame.music.isPlaying()){
|
||||||
|
SagittariusGame.music.stop();
|
||||||
|
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/HMO-MercuryCity.mp3"));
|
||||||
|
SagittariusGame.music.setLooping(true);
|
||||||
|
SagittariusGame.music.play();
|
||||||
|
}
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(this);
|
Gdx.input.setInputProcessor(this);
|
||||||
|
|
||||||
// arrows
|
// arrows
|
||||||
|
|
|
@ -18,6 +18,11 @@ public class SettingsScreen extends BaseScreen {
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
|
SagittariusGame.music.stop();
|
||||||
|
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Metre - Concentric.mp3"));
|
||||||
|
SagittariusGame.music.setLooping(true);
|
||||||
|
SagittariusGame.music.play();
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(uiStage);
|
Gdx.input.setInputProcessor(uiStage);
|
||||||
|
|
||||||
// Table creation
|
// Table creation
|
||||||
|
@ -35,6 +40,7 @@ public class SettingsScreen extends BaseScreen {
|
||||||
|
|
||||||
// disable music checkbox
|
// disable music checkbox
|
||||||
VisCheckBox disableMusic = new VisCheckBox("disable music");
|
VisCheckBox disableMusic = new VisCheckBox("disable music");
|
||||||
|
disableMusic.setChecked(SagittariusGame.disableMusic);
|
||||||
|
|
||||||
// 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));
|
||||||
|
@ -58,6 +64,14 @@ public class SettingsScreen extends BaseScreen {
|
||||||
SagittariusGame.soundsVolume = Float.parseFloat(musicVolume.getTextField().getText());
|
SagittariusGame.soundsVolume = Float.parseFloat(musicVolume.getTextField().getText());
|
||||||
SagittariusGame.debugMode = debugModeBox.isChecked();
|
SagittariusGame.debugMode = debugModeBox.isChecked();
|
||||||
|
|
||||||
|
// Deactivate music or not
|
||||||
|
if (disableMusic.isChecked() && SagittariusGame.music.isPlaying()){
|
||||||
|
SagittariusGame.music.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (!disableMusic.isChecked() && ! SagittariusGame.music.isPlaying()){
|
||||||
|
SagittariusGame.music.play();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,23 @@ public class StartScreen extends BaseScreen {
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
|
// A welcome music is played
|
||||||
|
if (!SagittariusGame.disableMusic){
|
||||||
|
if ( SagittariusGame.music != null ){
|
||||||
|
SagittariusGame.music.stop();
|
||||||
|
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3"));
|
||||||
|
SagittariusGame.music.setLooping(true);
|
||||||
|
SagittariusGame.music.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
SagittariusGame.music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3"));
|
||||||
|
SagittariusGame.music.setLooping(true);
|
||||||
|
SagittariusGame.music.play();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
Gdx.input.setInputProcessor(uiStage);
|
Gdx.input.setInputProcessor(uiStage);
|
||||||
|
|
||||||
// Table creation
|
// Table creation
|
||||||
|
|
Loading…
Reference in a new issue