use of com.badlogic.gdx.audio.Sound in project ProjektGG by eskalon.
the class ServerBrowserScreen method initUI.
@Override
protected void initUI() {
backgroundTexture = assetManager.get(BACKGROUND_IMAGE_PATH);
Sound clickSound = assetManager.get(BUTTON_SOUND);
// mainTable.setBackground(skin.getDrawable("parchment-small"));
Table serverTable = new Table();
ScrollPane pane = new ScrollPane(serverTable);
// TODO gegen echte Server-Daten austauschen
String ip = "127.0.0.1";
int port = 12345;
ImageTextButton joinButton = new ImageTextButton("Beitreten", skin);
joinButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
clickSound.play(1F);
game.getNetworkHandler().setUpConnectionAsClient(ip, port);
connectingDialog = new Dialog("Verbinden...", skin);
connectingDialog.text("Spiel beitreten...");
connectingDialog.show(stage);
return true;
}
});
ImageTextButton backButton = new ImageTextButton("Zur�ck", skin);
backButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
clickSound.play(1F);
game.pushScreen("mainMenu");
return true;
}
});
ImageTextButton createLobbyButton = new ImageTextButton("Spiel erstellen", skin);
createLobbyButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
clickSound.play(1F);
game.pushScreen("lobbyCreation");
return true;
}
});
ImageTextButton directConnectButton = new ImageTextButton("Direkt verbinden", skin);
directConnectButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
clickSound.play(1F);
TextField portInputField = new TextField("55789", skin);
portInputField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
TextField ipInputField = new TextField("127.0.0.1", skin);
Dialog dialog = new Dialog("Direkt verbinden", skin) {
public void result(Object obj) {
if ((Boolean) obj) {
game.getNetworkHandler().setUpConnectionAsClient(ipInputField.getText(), Integer.valueOf(portInputField.getText()));
connectingDialog = new Dialog("Verbinden...", skin);
connectingDialog.text("Spiel beitreten...");
connectingDialog.show(stage);
}
}
};
dialog.text("IP: ").button("Zur�ck", false).button("Verbinden", true).key(Keys.ENTER, true).key(Keys.ESCAPE, false);
dialog.getContentTable().add(ipInputField).width(170).row();
dialog.getContentTable().add(new Label("Port:", skin));
dialog.getContentTable().add(portInputField).width(90).left();
dialog.show(stage);
return true;
}
});
Table buttonTable = new Table();
buttonTable.add(backButton);
buttonTable.add(createLobbyButton).padLeft(55);
buttonTable.add(directConnectButton).padLeft(55);
serverTable.left().top().add(new Image((Texture) assetManager.get(TICK_IMAGE_PATH))).padRight(15).padLeft(12);
serverTable.add(new Label("Spiel 2", skin)).expandX();
serverTable.add(joinButton).padRight(12);
serverTable.row().padTop(20);
mainTable.add(serverTable).width(580).height(405).row();
mainTable.add(buttonTable).height(50).bottom();
}
use of com.badlogic.gdx.audio.Sound in project high-flyer by sangngh.
the class SoundPlayer method playSound.
public void playSound(String soundFilePath) {
Sound shutdownSound = Gdx.audio.newSound(Gdx.files.internal(soundFilePath));
shutdownSound.play();
}
use of com.badlogic.gdx.audio.Sound in project netthreads-libgdx by alistairrutherford.
the class SoundCache method add.
/**
* Add sound.
*
*/
private void add(SoundDefinition definition) {
Sound sound = null;
// Load sound
sound = Gdx.audio.newSound(Gdx.files.internal(definition.getPath()));
String name = definition.getName();
// Cache data.
data.put(name, sound);
// Cache details.
definitions.put(name, definition);
}
use of com.badlogic.gdx.audio.Sound in project ProjektGG by eskalon.
the class LobbyCreationScreen method initUI.
@Override
protected void initUI() {
backgroundTexture = assetManager.get(BACKGROUND_IMAGE_PATH);
Sound clickSound = assetManager.get(BUTTON_SOUND);
Label nameLabel = new Label("Name: ", skin);
Label portLabel = new Label("Port: ", skin);
TextField nameField = new TextField("", skin);
TextField portField = new TextField("55789", skin);
portField.setTextFieldFilter(new TextField.TextFieldFilter.DigitsOnlyFilter());
Label difficultyLabel = new Label("Schwierigkeit: ", skin);
CheckBox easyDifficultyCheckbox = new CheckBox("Einfach", skin);
CheckBox normalDifficultyCheckbox = new CheckBox("Normal", skin);
CheckBox hardDifficultyCheckbox = new CheckBox("Schwer", skin);
ButtonGroup speedGroup = new ButtonGroup();
speedGroup.add(easyDifficultyCheckbox);
speedGroup.add(normalDifficultyCheckbox);
speedGroup.add(hardDifficultyCheckbox);
normalDifficultyCheckbox.setChecked(true);
ImageTextButton backButton = new ImageTextButton("Zur�ck", skin);
backButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
game.pushScreen("serverBrowser");
clickSound.play(1F);
return true;
}
});
ImageTextButton createButton = new ImageTextButton("Erstellen", skin);
createButton.addListener(new InputListener() {
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (!nameField.getText().isEmpty() && !portField.getText().isEmpty()) {
clickSound.play(1F);
GameDifficulty difficulty = GameDifficulty.NORMAL;
if (speedGroup.getChecked().equals(easyDifficultyCheckbox)) {
difficulty = GameDifficulty.EASY;
} else if (speedGroup.getChecked().equals(normalDifficultyCheckbox)) {
difficulty = GameDifficulty.NORMAL;
} else if (speedGroup.getChecked().equals(hardDifficultyCheckbox)) {
difficulty = GameDifficulty.HARD;
}
// Sever & Client starten
game.getNetworkHandler().setUpConnectionAsHost(Integer.valueOf(portField.getText()), new GameSessionSetup(difficulty, GameMap.getMaps().get("Bamberg"), System.currentTimeMillis()));
connectingDialog = new Dialog("Starten...", skin);
connectingDialog.text("Server startet...");
connectingDialog.show(stage);
} else {
Dialog dialog = new Dialog("Felder unausgef�llt", skin);
dialog.text("Zum Starten m�ssen alle Felder ausgef�llt sein");
dialog.button("Ok", true);
dialog.key(Keys.ENTER, true);
dialog.show(stage);
}
return true;
}
});
Table settingsTable = new Table();
Table settings2ColTable = new Table();
Table settings3ColTable = new Table();
Table buttonTable = new Table();
settings2ColTable.add(nameLabel).padBottom(30);
settings2ColTable.add(nameField).padBottom(30).row();
settings2ColTable.add(portLabel);
settings2ColTable.add(portField).row();
settings3ColTable.add(difficultyLabel).colspan(3).row();
settings3ColTable.add(easyDifficultyCheckbox);
settings3ColTable.add(normalDifficultyCheckbox);
settings3ColTable.add(hardDifficultyCheckbox);
settingsTable.left().top().add(settings2ColTable).padBottom(40).row();
settingsTable.add(settings3ColTable).row();
buttonTable.add(backButton);
buttonTable.add(createButton).padLeft(65);
mainTable.add(settingsTable).width(580).height(405);
mainTable.row();
mainTable.add(buttonTable).height(50).bottom();
}
use of com.badlogic.gdx.audio.Sound in project Eidolons by IDemiurge.
the class Player method playNow.
public void playNow(SoundFx sound) {
if (SoundMaster.isBlockNextSound()) {
SoundMaster.setBlockNextSound(false);
return;
}
if (sound.getSound().endsWith(".ini"))
return;
try {
Sound soundFile = Gdx.audio.newSound(Gdx.files.getFileHandle(sound.getSound(), FileType.Absolute));
soundFile.setVolume(0, sound.getVolume());
soundFile.play();
lastplayed.push(sound.getSound());
} catch (Exception ex) {
main.system.ExceptionMaster.printStackTrace(ex);
}
}
Aggregations