ajout dans le menu
This commit is contained in:
parent
638235acfa
commit
a8e400d22d
|
@ -1,8 +1,11 @@
|
|||
package sagittarius;
|
||||
|
||||
import com.badlogic.gdx.Game;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.kotcrab.vis.ui.VisUI;
|
||||
|
||||
import com.badlogic.gdx.audio.Sound;
|
||||
import com.badlogic.gdx.audio.Music;
|
||||
import com.badlogic.gdx.files.*;
|
||||
import sagittarius.view.*;
|
||||
|
||||
public class SagittariusGame extends Game {
|
||||
|
@ -10,7 +13,7 @@ public class SagittariusGame extends Game {
|
|||
// Constants
|
||||
public static float G = 100;
|
||||
public static boolean debugMode = true;
|
||||
|
||||
public static Music music;
|
||||
private static Game game;
|
||||
|
||||
public SagittariusGame() {
|
||||
|
@ -27,6 +30,14 @@ public class SagittariusGame extends Game {
|
|||
|
||||
@Override
|
||||
public void create() {
|
||||
|
||||
/* A welcome music is played */
|
||||
music = Gdx.audio.newMusic(Gdx.files.internal("core/assets/sounds/Ghostrifter-Deflector.mp3"));
|
||||
music.play();
|
||||
|
||||
// Default volume
|
||||
music.setVolume(0.3f);
|
||||
|
||||
VisUI.load();
|
||||
game.setScreen(new SettingsScreen());
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import com.kotcrab.vis.ui.widget.VisTextButton;
|
|||
import com.kotcrab.vis.ui.widget.spinner.SimpleFloatSpinnerModel;
|
||||
import com.kotcrab.vis.ui.widget.spinner.Spinner;
|
||||
|
||||
|
||||
import sagittarius.SagittariusGame;
|
||||
|
||||
public class SettingsScreen extends BaseScreen {
|
||||
|
@ -34,6 +35,12 @@ public class SettingsScreen extends BaseScreen {
|
|||
VisCheckBox debugModeBox = new VisCheckBox("debug mode");
|
||||
debugModeBox.setChecked(SagittariusGame.debugMode);
|
||||
|
||||
|
||||
|
||||
// Change volume of the music
|
||||
Spinner musicVolume= new Spinner("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
|
||||
|
||||
|
||||
// save button
|
||||
VisTextButton saveButton = new VisTextButton("Save");
|
||||
saveButton.addListener(new ActorGestureListener() {
|
||||
|
@ -42,6 +49,7 @@ public class SettingsScreen extends BaseScreen {
|
|||
super.tap(event, x, y, count, button);
|
||||
|
||||
SagittariusGame.G = Float.parseFloat(gConstField.getTextField().getText());
|
||||
SagittariusGame.music.setVolume(Float.parseFloat(musicVolume.getTextField().getText()));
|
||||
SagittariusGame.debugMode = debugModeBox.isChecked();
|
||||
|
||||
}
|
||||
|
@ -60,6 +68,8 @@ public class SettingsScreen extends BaseScreen {
|
|||
// Table structure
|
||||
table.add(gConstField).width(250);
|
||||
table.row();
|
||||
table.add(musicVolume).width(250);
|
||||
table.row();
|
||||
table.add(debugModeBox).align(Align.left);
|
||||
table.row();
|
||||
table.add(saveButton).width(250);
|
||||
|
|
Loading…
Reference in a new issue