Search in sources :

Example 6 with Sound

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();
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) Sound(com.badlogic.gdx.audio.Sound) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) Texture(com.badlogic.gdx.graphics.Texture) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) ScrollPane(com.badlogic.gdx.scenes.scene2d.ui.ScrollPane) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 7 with Sound

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();
}
Also used : Sound(com.badlogic.gdx.audio.Sound)

Example 8 with Sound

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);
}
Also used : Sound(com.badlogic.gdx.audio.Sound)

Example 9 with Sound

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();
}
Also used : ImageTextButton(com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) GameDifficulty(de.gg.data.GameSessionSetup.GameDifficulty) Sound(com.badlogic.gdx.audio.Sound) InputListener(com.badlogic.gdx.scenes.scene2d.InputListener) ButtonGroup(com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup) GameSessionSetup(de.gg.data.GameSessionSetup) CheckBox(com.badlogic.gdx.scenes.scene2d.ui.CheckBox) Dialog(com.badlogic.gdx.scenes.scene2d.ui.Dialog) TextField(com.badlogic.gdx.scenes.scene2d.ui.TextField) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent)

Example 10 with Sound

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);
    }
}
Also used : Sound(com.badlogic.gdx.audio.Sound) IOException(java.io.IOException)

Aggregations

Sound (com.badlogic.gdx.audio.Sound)10 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)4 InputListener (com.badlogic.gdx.scenes.scene2d.InputListener)4 ImageTextButton (com.badlogic.gdx.scenes.scene2d.ui.ImageTextButton)4 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)3 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)3 Dialog (com.badlogic.gdx.scenes.scene2d.ui.Dialog)2 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 ScrollPane (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane)2 Music (com.badlogic.gdx.audio.Music)1 Texture (com.badlogic.gdx.graphics.Texture)1 ButtonGroup (com.badlogic.gdx.scenes.scene2d.ui.ButtonGroup)1 CheckBox (com.badlogic.gdx.scenes.scene2d.ui.CheckBox)1 TextArea (com.badlogic.gdx.scenes.scene2d.ui.TextArea)1 TextFieldListener (com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener)1 GameSessionSetup (de.gg.data.GameSessionSetup)1 GameDifficulty (de.gg.data.GameSessionSetup.GameDifficulty)1 NewChatMessagEvent (de.gg.event.NewChatMessagEvent)1 NetworkHandler (de.gg.network.NetworkHandler)1