ajout de son pour les menus

This commit is contained in:
heurtet 2021-05-14 14:58:14 +02:00
parent 5ac5761d19
commit 4856b3aa03
7 changed files with 123 additions and 28 deletions

View file

@ -0,0 +1,31 @@
package sagittarius.view.ButtonSounded;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.audio.Sound;
import sagittarius.SagittariusGame;
public class ButtonTextSounded extends com.kotcrab.vis.ui.widget.VisTextButton{
private Sound buttonclicked = Gdx.audio.newSound(Gdx.files.internal("core/assets/sounds/effects/clickbutton.mp3"));
public ButtonTextSounded(String name){
super(name);
this.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
super.tap(event, x, y, count, button);
if ( !SagittariusGame.disableSounds){
buttonclicked.play();
}
}
});
}
}

View file

@ -0,0 +1,31 @@
package sagittarius.view.ButtonSounded;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.audio.Sound;
import sagittarius.SagittariusGame;
public class CheckBoxSounded extends com.kotcrab.vis.ui.widget.VisCheckBox{
private Sound buttonclicked = Gdx.audio.newSound(Gdx.files.internal("core/assets/sounds/effects/clickbutton.mp3"));
public CheckBoxSounded(String name){
super(name);
this.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
super.tap(event, x, y, count, button);
if ( !SagittariusGame.disableSounds){
buttonclicked.play();
}
}
});
}
}

View file

@ -0,0 +1,32 @@
package sagittarius.view.ButtonSounded;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.kotcrab.vis.ui.widget.spinner.SimpleFloatSpinnerModel;
import com.badlogic.gdx.audio.Sound;
import sagittarius.SagittariusGame;
public class SpinnerSounded extends com.kotcrab.vis.ui.widget.spinner.Spinner{
private Sound buttonclicked = Gdx.audio.newSound(Gdx.files.internal("core/assets/sounds/effects/clickbutton.mp3"));
public SpinnerSounded(String name,SimpleFloatSpinnerModel SpinnerModel){
super(name,SpinnerModel);
this.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
super.tap(event, x, y, count, button);
if ( !SagittariusGame.disableSounds){
buttonclicked.play();
}
}
});
}
}

View file

@ -5,7 +5,8 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisTable;
import com.kotcrab.vis.ui.widget.VisTextButton;
import com.badlogic.gdx.audio.Sound;
import sagittarius.view.ButtonSounded.*;
import sagittarius.SagittariusGame;
@ -34,7 +35,7 @@ public class CreditScreen extends BaseScreen {
// go back button
VisTextButton returnButton = new VisTextButton("Go Back");
ButtonTextSounded returnButton = new ButtonTextSounded("Go Back");
returnButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {

View file

@ -5,11 +5,11 @@ import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisCheckBox;
import com.kotcrab.vis.ui.widget.VisTable;
import com.kotcrab.vis.ui.widget.VisTextButton;
import com.kotcrab.vis.ui.widget.spinner.SimpleFloatSpinnerModel;
import com.kotcrab.vis.ui.widget.spinner.Spinner;
import com.badlogic.gdx.audio.Sound;
import sagittarius.view.ButtonSounded.*;
import sagittarius.SagittariusGame;
@ -38,21 +38,21 @@ public class ResumeScreen extends BaseScreen {
uiStage.addActor(table);
// disable music checkbox
VisCheckBox disableMusic = new VisCheckBox("disable music");
CheckBoxSounded disableMusic = new CheckBoxSounded("disable music");
disableMusic.setChecked(SagittariusGame.disableMusic);
// Change volume of the music
Spinner musicVolume= new Spinner("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
SpinnerSounded musicVolume= new SpinnerSounded("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
// disable sound checkbox
VisCheckBox disableSounds= new VisCheckBox("disable sounds");
CheckBoxSounded disableSounds= new CheckBoxSounded("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));
SpinnerSounded musicSounds= new SpinnerSounded("Sounds Volume:", new SimpleFloatSpinnerModel(SagittariusGame.soundsVolume, 0f, 1.0f, 0.01f, 3));
// save button
VisTextButton applyButton = new VisTextButton("Apply");
ButtonTextSounded applyButton = new ButtonTextSounded("Apply");
applyButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
@ -84,7 +84,7 @@ public class ResumeScreen extends BaseScreen {
});
// Resume button
VisTextButton resumeButton = new VisTextButton("Resume");
ButtonTextSounded resumeButton = new ButtonTextSounded("Resume");
resumeButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
@ -102,7 +102,7 @@ public class ResumeScreen extends BaseScreen {
});
// go back to main menu
VisTextButton returnMain = new VisTextButton("Main Menu");
ButtonTextSounded returnMain = new ButtonTextSounded("Main Menu");
returnMain.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {

View file

@ -5,11 +5,10 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.badlogic.gdx.utils.Align;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisCheckBox;
import com.kotcrab.vis.ui.widget.VisTable;
import com.kotcrab.vis.ui.widget.VisTextButton;
import com.kotcrab.vis.ui.widget.spinner.SimpleFloatSpinnerModel;
import com.kotcrab.vis.ui.widget.spinner.Spinner;
import com.badlogic.gdx.audio.Sound;
import sagittarius.view.ButtonSounded.*;
import sagittarius.SagittariusGame;
@ -33,29 +32,29 @@ public class SettingsScreen extends BaseScreen {
uiStage.addActor(table);
// G constant field
Spinner gConstField = new Spinner("G constant:", new SimpleFloatSpinnerModel(SagittariusGame.G, 1f, 500f, 0.5f, 3));
SpinnerSounded gConstField = new SpinnerSounded("G constant:", new SimpleFloatSpinnerModel(SagittariusGame.G, 1f, 500f, 0.5f, 3));
// dubug mode checkbox
VisCheckBox debugModeBox = new VisCheckBox("debug mode");
CheckBoxSounded debugModeBox = new CheckBoxSounded("debug mode");
debugModeBox.setChecked(SagittariusGame.debugMode);
// disable music checkbox
VisCheckBox disableMusic = new VisCheckBox("disable music");
CheckBoxSounded disableMusic = new CheckBoxSounded("disable music");
disableMusic.setChecked(SagittariusGame.disableMusic);
// Change volume of the music
Spinner musicVolume= new Spinner("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
SpinnerSounded musicVolume= new SpinnerSounded("Music Volume:", new SimpleFloatSpinnerModel(SagittariusGame.music.getVolume(), 0f, 1.0f, 0.01f, 3));
// disable sound checkbox
VisCheckBox disableSounds= new VisCheckBox("disable sounds");
CheckBoxSounded disableSounds= new CheckBoxSounded("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));
SpinnerSounded musicSounds= new SpinnerSounded("Sounds Volume:", new SimpleFloatSpinnerModel(SagittariusGame.soundsVolume, 0f, 1.0f, 0.01f, 3));
// save button
VisTextButton saveButton = new VisTextButton("Save");
ButtonTextSounded saveButton = new ButtonTextSounded("Save");
saveButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
@ -90,7 +89,7 @@ public class SettingsScreen extends BaseScreen {
});
// go back button
VisTextButton returnButton = new VisTextButton("Go Back");
ButtonTextSounded returnButton = new ButtonTextSounded("Go Back");
returnButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {

View file

@ -5,7 +5,8 @@ import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.utils.ActorGestureListener;
import com.kotcrab.vis.ui.VisUI;
import com.kotcrab.vis.ui.widget.VisTable;
import com.kotcrab.vis.ui.widget.VisTextButton;
import com.badlogic.gdx.audio.Sound;
import sagittarius.view.ButtonSounded.ButtonTextSounded;
import sagittarius.SagittariusGame;
@ -39,7 +40,7 @@ public class StartScreen extends BaseScreen {
uiStage.addActor(table);
// quick Button
VisTextButton playButton = new VisTextButton("Play");
ButtonTextSounded playButton = new ButtonTextSounded("Play");
playButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
@ -48,7 +49,7 @@ public class StartScreen extends BaseScreen {
}
});
VisTextButton settingsButton = new VisTextButton("Settings");
ButtonTextSounded settingsButton = new ButtonTextSounded("Settings");
settingsButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
@ -57,7 +58,7 @@ public class StartScreen extends BaseScreen {
}
});
VisTextButton creditButton = new VisTextButton("Credits");
ButtonTextSounded creditButton = new ButtonTextSounded("Credits");
creditButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {
@ -68,7 +69,7 @@ public class StartScreen extends BaseScreen {
// Quit button
VisTextButton quitButton = new VisTextButton("Exit");
ButtonTextSounded quitButton = new ButtonTextSounded("Exit");
quitButton.addListener(new ActorGestureListener() {
@Override
public void tap(InputEvent event, float x, float y, int count, int button) {