Example usage for com.badlogic.gdx.scenes.scene2d Stage Stage

List of usage examples for com.badlogic.gdx.scenes.scene2d Stage Stage

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d Stage Stage.

Prototype

public Stage(Viewport viewport, Batch batch) 

Source Link

Document

Creates a stage with the specified viewport and batch.

Usage

From source file:ca.hiphiparray.amazingmaze.ContinueScreen.java

License:Open Source License

/**
 * The constructor for ContinueScreen./*w w  w.  j av  a 2 s  . c  o m*/
 *
 * @param game the {@link AmazingMazeGame} instance that is managing this screen.
 * @param won if the player won.
 */
public ContinueScreen(final AmazingMazeGame game, final boolean won) {
    this.game = game;

    stage = new Stage(new ScreenViewport(), this.game.batch);
    labelTable = new Table();
    optionTable = new Table();
    labelTable.setFillParent(true);
    labelTable.top().center();
    optionTable.setFillParent(true);
    optionTable.bottom();
    labelTable.background(new TextureRegionDrawable(
            new TextureRegion(this.game.assets.manager.get(Assets.MINI_BACKGROUND, Texture.class))));

    if (won) {
        resultLabel = new Label("You got the antidote!", game.assets.skin, Assets.WHITE_SANS_STYLE);
        resultDescriptionLabel = new Label("Continute searching for more to help others or quit the maze?",
                game.assets.skin, Assets.WHITE_SANS_STYLE);
    } else {
        resultLabel = new Label("You lose!", game.assets.skin, Assets.WHITE_SANS_STYLE);
        resultDescriptionLabel = new Label("Go back to last checkpoint or quit?", game.assets.skin,
                Assets.WHITE_SANS_STYLE);
    }
    currentScoreLabel = new Label("Your current score: " + game.save.getScore(), game.assets.skin,
            Assets.WHITE_SANS_STYLE);

    continueButton = new TextButton("Continue", game.assets.skin);
    continueButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (continueButton.isPressed()) {
                if (!won) {
                    int nextLevel = 5 * (game.save.getLevel() / 5) + 1;
                    int startScore = game.save.getStartScore();
                    game.save.resetSave();
                    game.save.setLevel(nextLevel);
                    game.save.setStartScore(startScore);
                    game.save.setScore(startScore);
                } else {
                    game.save.setStartScore(game.save.getScore());
                }
                game.setScreen(new MazeScreen(game, false));
            }
        }
    });

    quitButton = new TextButton("Quit", game.assets.skin);
    quitButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (quitButton.isPressed()) {
                highScoreDialog();
            }
        }
    });

    labelTable.add(resultLabel).pad(20);
    labelTable.row();
    labelTable.add(resultDescriptionLabel).pad(20);
    labelTable.row();
    labelTable.add(currentScoreLabel).pad(20);
    optionTable.add(continueButton).minSize(Gdx.graphics.getWidth() / 8, Gdx.graphics.getHeight() / 20)
            .maxSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight() / 8)
            .prefSize(Gdx.graphics.getWidth() / 5, Gdx.graphics.getHeight() / 10).padBottom(10).pad(20);
    optionTable.row();
    optionTable.add(quitButton).minSize(Gdx.graphics.getWidth() / 8, Gdx.graphics.getHeight() / 20)
            .maxSize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight() / 8)
            .prefSize(Gdx.graphics.getWidth() / 5, Gdx.graphics.getHeight() / 10).pad(20).padBottom(40);
    stage.addActor(labelTable);
    stage.addActor(optionTable);
}

From source file:ca.hiphiparray.amazingmaze.FishMiniGame.java

License:Open Source License

/**
 * Constructor for FishMiniGame./*from  w ww. j  ava2 s .c o  m*/
 *
 * @param game the {@link AmazingMazeGame} instance that is managing this screen.
 * @param player the {@link Player} instance that completed the last level.
 */
public FishMiniGame(final AmazingMazeGame game, Player player) {
    this.game = game;
    this.player = player;
    fishNumber = new int[5];

    fishNumber[0] = this.player.blueCollected;
    fishNumber[1] = this.player.purpleCollected;
    fishNumber[2] = this.player.greenCollected;
    fishNumber[3] = this.player.redCollected;
    fishNumber[4] = this.player.orangeCollected;

    answer = 0;
    for (int i = 0; i < fishNumber.length; i++) {
        answer += fishNumber[i] * fishValue[i];
    }

    stage = new Stage(new ScreenViewport(), this.game.batch);

    menuTable = new Table();
    fishTable = new Table();

    canvas = new Canvas(
            new Pixmap(Gdx.graphics.getWidth(), Gdx.graphics.getHeight() + shift, Pixmap.Format.RGB565));

    menuTable.setFillParent(true);
    menuTable.top();
    fishTable.bottom();
    fishTable.setFillParent(true);

    fishImage = new Image[5];

    TextureAtlas atlas = this.game.assets.manager.get(Assets.GAME_ATLAS_LOCATION, TextureAtlas.class);
    fishImage[0] = new Image(atlas.findRegion(Assets.FISH + Assets.BLUE_MODIFIER));
    fishImage[0].setScale(4f);
    fishImage[1] = new Image(atlas.findRegion(Assets.FISH + Assets.PURPLE_MODIFIER));
    fishImage[1].setScale(4f);
    fishImage[2] = new Image(atlas.findRegion(Assets.FISH + Assets.GREEN_MODIFIER));
    fishImage[2].setScale(4f);
    fishImage[3] = new Image(atlas.findRegion(Assets.FISH + Assets.RED_MODIFIER));
    fishImage[3].setScale(4f);
    fishImage[4] = new Image(atlas.findRegion(Assets.FISH + Assets.ORANGE_MODIFIER));
    fishImage[4].setScale(4f);

    pencilButton = new Button(new TextureRegionDrawable(
            new TextureRegion(this.game.assets.manager.get(Assets.PENCIL_BUTTON, Texture.class))));
    pencilButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (pencilButton.isPressed()) {
                canvas.setColor(drawColor);
            }
        }
    });

    eraserButton = new Button(new TextureRegionDrawable(
            new TextureRegion(this.game.assets.manager.get(Assets.ERASER_BUTTON, Texture.class))));
    eraserButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (eraserButton.isPressed()) {
                canvas.setColor(clearColor);
            }
        }
    });

    helpButton = new Button(new TextureRegionDrawable(
            new TextureRegion(this.game.assets.manager.get(Assets.HELP_BUTTON, Texture.class))));
    helpButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (helpButton.isPressed()) {
                Label.LabelStyle labelStyle = new Label.LabelStyle(
                        game.assets.getFont(Assets.MONO_REGULAR, Assets.SMALL_FONT_SIZE), Color.WHITE);
                final Dialog dialog = new Dialog("Help", game.assets.skin);
                final TextButton okButton = new TextButton("OK", game.assets.skin);
                dialog.getButtonTable().bottom();
                Label label = new Label("Find the total value of fish that you retrieved!\n"
                        + "Each colour corresponds to the colour of Canadian money.\n"
                        + "The numbers correspond to each number of fish you got.\n\n"
                        + "In case you forgot: blue is 5, purple is 10, green is 20, red is 50, and orange is 100.",
                        labelStyle);
                label.setScale(.5f);
                label.setWrap(true);
                label.setAlignment(Align.center);
                dialog.add(label).width(500).pad(50);
                dialog.add(okButton).bottom();
                okButton.addListener(new ChangeListener() {
                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        if (okButton.isPressed()) {
                            dialog.hide();
                            canvas.setColor(drawColor);
                        }
                    }
                });
                dialog.key(Keys.ENTER, true);
                dialog.show(stage);
            }
        }
    });

    checkButton = new Button(new TextureRegionDrawable(
            new TextureRegion(this.game.assets.manager.get(Assets.CHECK_BUTTON, Texture.class))));
    checkButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            dialog();
        }
    });

    clearButton = new Button(new TextureRegionDrawable(
            new TextureRegion(this.game.assets.manager.get(Assets.CLEAR_BUTTON, Texture.class))));
    clearButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (clearButton.isPressed()) {
                canvas.clear();
                canvas.setColor(drawColor);
            }
        }
    });

    answerField = new TextField("", game.assets.skin);
    answerField.setTextFieldListener(new TextFieldListener() {
        @Override
        public void keyTyped(TextField textField, char key) {
            if (key == (char) 13) {
                stage.unfocus(answerField);
                dialog();
            }
        }
    });
    stage.addActor(menuTable);
    stage.addActor(canvas);
    stage.addActor(fishTable);

    menuTable.clear();
    fishTable.clear();
    helpButton.right();
    menuTable.background(new TextureRegionDrawable(
            new TextureRegion(this.game.assets.manager.get(Assets.MINI_BACKGROUND, Texture.class))));
    menuTable.add(pencilButton).pad(10).size(64);
    menuTable.add(eraserButton).pad(10).size(64);
    menuTable.add(clearButton).pad(10).size(64);
    menuTable.add(helpButton).pad(10).size(64);

    menuTable.row();

    Label.LabelStyle labelStyle = new Label.LabelStyle(
            game.assets.getFont(Assets.SANS_REGULAR, Assets.REGULAR_FONT_SIZE), Color.WHITE);

    for (int i = 0; i < 5; i++) {
        fishTable.add(fishImage[i]).bottom().left().padLeft(10);
    }
    fishTable.add(answerField).minWidth(150).padLeft(150);
    fishTable.add(checkButton).pad(10).size(64);
    fishTable.row();

    for (int i = 0; i < 5; i++) {
        fishTable.add(new Label(fishNumber[i] + "", labelStyle)).pad(30).center();
    }
    fishTable.row();

    setupPauseMenu();
    input = new InputMultiplexer(stage, this);
    input.addProcessor(pauseMenu);
}

From source file:ca.hiphiparray.amazingmaze.FishMiniGame.java

License:Open Source License

/** Create the pause menu. */
private void setupPauseMenu() {
    pauseMenu = new Stage(new ScreenViewport(), game.batch);

    Table table = new Table();
    table.setFillParent(true);/*from w  w w.j a  va 2 s . co m*/
    table.center();
    pauseMenu.addActor(table);

    TextButton resumeButton = new TextButton("Resume", game.assets.skin);
    resumeButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            paused = false;
        }
    });
    table.add(resumeButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
    table.row();

    TextButton settingsButton = new TextButton("Settings", game.assets.skin);
    final Screen sourceScreen = this;
    settingsButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.settingsScreen.setSourceScreen(sourceScreen);
            game.setScreen(game.settingsScreen);
        }
    });
    table.add(settingsButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
    table.row();

    TextButton quitButton = new TextButton("Quit", game.assets.skin);
    quitButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.save.setLevel(game.save.getLevel() - 1);
            game.setScreen(game.menuScreen);
        }
    });
    table.add(quitButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
}

From source file:ca.hiphiparray.amazingmaze.HelpScreen.java

License:Open Source License

/**
 * Creates the help screen./*  w  w  w.j  a  v a 2s  .  c  o  m*/
 *
 * @param game The instance for the AmazingMazeGame used.
 */
public HelpScreen(final AmazingMazeGame game) {
    super(game, true);
    instruct = new Label(
            "Check the logic gates to find the state of each wire and make your way through the maze. Be careful to avoid\nany wires that are on, as that means that they are electrified!",
            game.assets.skin, Assets.HUD_STYLE);
    instruct.setAlignment(Align.center);
    clicks = new Label(
            "Mark the wires by clicking on the gates. Left click = on. Right click = off. Middle click = unknown.",
            game.assets.skin, Assets.HUD_STYLE);
    clicks.setAlignment(Align.center);

    super.hud = new Stage(new ScreenViewport(), game.batch);

    table = new Table();
    table.top();
    table.setFillParent(true);
    super.hud.addActor(table);

    table.add(instruct).top().pad(10);
    table.row();
    table.add(clicks).pad(10);
    table.row();
    table.add().expand();
    table.row();

    gates = new Label[] { new Label("AND Gate", game.assets.skin, Assets.HUD_STYLE),
            new Label("NAND Gate", game.assets.skin, Assets.HUD_STYLE),
            new Label("OR Gate", game.assets.skin, Assets.HUD_STYLE),
            new Label("NOR Gate", game.assets.skin, Assets.HUD_STYLE),
            new Label("XOR Gate", game.assets.skin, Assets.HUD_STYLE) };

    TextureAtlas atlas = game.assets.manager.get(Assets.GAME_ATLAS_LOCATION, TextureAtlas.class); // Reference used for readability.
    gatePics = new Image[] {
            new Image(atlas.findRegion(Assets.AND_GATE + Assets.UNKNOWN_MODIFIER + Assets.UP_MODIFIER)),
            new Image(atlas.findRegion(Assets.NAND_GATE + Assets.UNKNOWN_MODIFIER + Assets.UP_MODIFIER)),
            new Image(atlas.findRegion(Assets.OR_GATE + Assets.UNKNOWN_MODIFIER + Assets.UP_MODIFIER)),
            new Image(atlas.findRegion(Assets.NOR_GATE + Assets.UNKNOWN_MODIFIER + Assets.UP_MODIFIER)),
            new Image(atlas.findRegion(Assets.XOR_GATE + Assets.UNKNOWN_MODIFIER + Assets.UP_MODIFIER)), };

    truthTable = new Table();
    truthTable.top().center();
    table.add(truthTable).bottom().pad(10);

    truthTable.add();
    for (int x = 0; x < gatePics.length; x++) {
        truthTable.add(gatePics[x]).size(gatePics[x].getWidth() * 2, gatePics[x].getHeight() * 2).pad(5);
    }
    truthTable.row();
    truthTable.add();
    for (int x = 0; x < gates.length; x++) {
        truthTable.add(gates[x]).pad(5);
    }
    truthTable.row();

    truth = new Label[][] {
            { new Label("false and false", game.assets.skin, Assets.HUD_STYLE),
                    new Label("off", game.assets.skin, Assets.HUD_STYLE),
                    new Label("on", game.assets.skin, Assets.HUD_STYLE),
                    new Label("off", game.assets.skin, Assets.HUD_STYLE),
                    new Label("on", game.assets.skin, Assets.HUD_STYLE),
                    new Label("off", game.assets.skin, Assets.HUD_STYLE) },
            { new Label("true and false", game.assets.skin, Assets.HUD_STYLE),
                    new Label("off", game.assets.skin, Assets.HUD_STYLE),
                    new Label("on", game.assets.skin, Assets.HUD_STYLE),
                    new Label("on", game.assets.skin, Assets.HUD_STYLE),
                    new Label("off", game.assets.skin, Assets.HUD_STYLE),
                    new Label("on", game.assets.skin, Assets.HUD_STYLE) },
            { new Label("true and true", game.assets.skin, Assets.HUD_STYLE),
                    new Label("on", game.assets.skin, Assets.HUD_STYLE),
                    new Label("off", game.assets.skin, Assets.HUD_STYLE),
                    new Label("on", game.assets.skin, Assets.HUD_STYLE),
                    new Label("off", game.assets.skin, Assets.HUD_STYLE),
                    new Label("off", game.assets.skin, Assets.HUD_STYLE) } };

    for (int x = 0; x < truth.length; x++) {
        for (int y = 0; y < truth[x].length; y++) {
            truthTable.add(truth[x][y]).pad(5);
        }
        truthTable.row();
    }
}

From source file:ca.hiphiparray.amazingmaze.HighScoresScreen.java

License:Open Source License

/**
 * Create the high scores screen./*  w  w  w  .j  av  a  2 s.  c  o m*/
 *
 * @param game the {@link AmazingMazeGame} instance managing this screen.
 */
public HighScoresScreen(final AmazingMazeGame game) {
    this.game = game;
    this.stage = new Stage(new ScreenViewport(), this.game.batch);
}

From source file:ca.hiphiparray.amazingmaze.MainMenuScreen.java

License:Open Source License

/**
 * Creates the main menu.//from ww w.  j  a va 2  s .  c  om
 *
 * @param game The instance for the AmazingMazeGame used.
 */
public MainMenuScreen(final AmazingMazeGame game) {
    this.game = game;
    menu = new Stage(new ScreenViewport(), this.game.batch);

    table = new Table();

    table.setFillParent(true);
    table.bottom();
    menu.addActor(table);

    menuTitle = new Image(this.game.assets.manager.get(Assets.GAME_LOGO, Texture.class));

    // Play
    playButton = new TextButton("Play", game.assets.skin);
    playButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (playButton.isPressed()) {
                game.setScreen(game.storyScreen);
            }
        }
    });

    // Help
    helpButton = new TextButton("Help", game.assets.skin);
    helpButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (helpButton.isPressed()) {
                game.setScreen(new HelpScreen(game));
            }
        }
    });

    // Settings
    settingsButton = new TextButton("Settings", game.assets.skin);
    settingsButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (settingsButton.isPressed()) {
                game.setScreen(game.settingsScreen);
            }
        }
    });

    // Credits
    creditsButton = new TextButton("Credits", game.assets.skin);
    creditsButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (creditsButton.isPressed()) {
                game.setScreen(new CreditsScreen(game));
            }
        }
    });

    licenseDialog = new Dialog("License Information", game.assets.skin);
    licenseDialog.button("Okay");

    licenseDialog.text(
            "Amazing Maze is an educational game created in Java with the libGDX library.\n"
                    + "Copyright (C) 2017 Hip Hip Array\n" + "\n"
                    + "Amazing Maze is free software: you can redistribute it and/or modify\n"
                    + "it under the terms of the GNU General Public License as published by\n"
                    + "the Free Software Foundation, either version 3 of the License, or\n"
                    + "(at your option) any later version.\n" + "\n"
                    + "Amazing Maze is distributed in the hope that it will be useful,\n"
                    + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
                    + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
                    + "GNU General Public License for more details.\n" + "\n"
                    + "You should have received a copy of the GNU General Public License\n"
                    + "along with Amazing Maze. If not, see <http://www.gnu.org/licenses/>.",
            game.assets.skin.get(Assets.WHITE_SANS_STYLE, LabelStyle.class));

    // License
    licenseButton = new TextButton("License", game.assets.skin);
    licenseButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (licenseButton.isPressed()) {
                licenseDialog.show(menu);
            }
        }
    });

    // High scores
    highScoresButton = new TextButton("High Scores", game.assets.skin);
    highScoresButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (highScoresButton.isPressed()) {
                game.setScreen(game.highScoresScreen);
            }
        }
    });

    // Quit
    quitButton = new TextButton("Quit", game.assets.skin);
    quitButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (quitButton.isPressed()) {
                game.save.writeScores();
                game.save.writeSettings();
                Gdx.app.exit();
            }
        }
    });
}

From source file:ca.hiphiparray.amazingmaze.MazeScreen.java

License:Open Source License

/** Create the pause menu. */
private void setupPauseMenu() {
    pauseMenu = new Stage(new ScreenViewport(), game.batch);

    Table table = new Table();
    table.setFillParent(true);//from   w w w .j ava2  s.  c o m
    table.center();
    pauseMenu.addActor(table);

    TextButton resumeButton = new TextButton("Resume", game.assets.skin);
    resumeButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            paused = false;
        }
    });
    table.add(resumeButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
    table.row();

    TextButton settingsButton = new TextButton("Settings", game.assets.skin);
    final Screen sourceScreen = this;
    settingsButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.settingsScreen.setSourceScreen(sourceScreen);
            game.setScreen(game.settingsScreen);
        }
    });
    table.add(settingsButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
    table.row();

    TextButton quitButton = new TextButton("Main Menu", game.assets.skin);
    quitButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.setScreen(game.menuScreen);
        }
    });
    table.add(quitButton).pad(10).width(Gdx.graphics.getWidth() / 4).height(Gdx.graphics.getHeight() / 8);
}

From source file:ca.hiphiparray.amazingmaze.MazeScreen.java

License:Open Source License

/** Create the game HUD. */
private void setupHUD() {
    hud = new Stage(new ScreenViewport(), game.batch);

    Table table = new Table();
    table.setFillParent(true);/* w  w w.  j  a  v a 2s.c o m*/
    table.top().left();
    hud.addActor(table);

    Label level = new Label("Level " + game.save.getLevel(), game.assets.skin, Assets.HUD_STYLE);
    table.add(level).colspan(2);
    table.row();

    Image lifeIcon = new Image(game.assets.manager.get(Assets.LIFE_HUD_IMAGE, Texture.class));
    table.add(lifeIcon).pad(Gdx.graphics.getWidth() / 128).left();

    livesLeft = new Label("", game.assets.skin, Assets.HUD_STYLE);
    table.add(livesLeft);

    updateLives(-2);
}

From source file:ca.hiphiparray.amazingmaze.SettingsScreen.java

License:Open Source License

/**
 * Create a new SettingsScreen.//from  w w w.  j a v  a2 s.  c o  m
 *
 * @param game Instance of AmazingMazeGame to be used
 */
public SettingsScreen(final AmazingMazeGame game) {
    this.game = game;
    this.sourceScreen = game.menuScreen;
    settings = new Stage(new ScreenViewport(), this.game.batch);
    multiplexer = new InputMultiplexer();
    multiplexer.addProcessor(settings);
    multiplexer.addProcessor(this);
    table = new Table();
    table.top();
    table.setFillParent(true);
    controlsTable = new Table();

    settings.addActor(table);

    Skin skin = game.assets.skin;

    screenHeader = new Label("Settings", game.assets.skin, Assets.SANS_HEADER_STYLE);

    musicSlider = new Slider(0, 1, 0.1f, false, game.assets.skin);
    musicSlider.setValue(game.save.getMusicLevel());
    musicSlider.setAnimateDuration(0.25f);

    musicSlider.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            game.music.setVolume(musicSlider.getValue());
            game.save.setMusicLevel(game.music.getVolume());
        }
    });
    musicSliderLabel = new Label("Music Volume", game.assets.skin);

    controlsHeader = new Label("Controls", game.assets.skin);

    actions = new Label[] { new Label("Up", game.assets.skin), new Label("Down", game.assets.skin),
            new Label("Left", game.assets.skin), new Label("Right", game.assets.skin),
            new Label("Pause", game.assets.skin) };

    actionControls = new TextButton[] { new TextButton(Keys.toString(game.save.getUpButton()), skin),
            new TextButton(Keys.toString(game.save.getDownButton()), skin),
            new TextButton(Keys.toString(game.save.getLeftButton()), skin),
            new TextButton(Keys.toString(game.save.getRightButton()), skin),
            new TextButton(Keys.toString(game.save.getPauseButton()), skin) };

    actionControls[0].addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (actionControls[0].isPressed()) {
                updateControls(0);
            }
        }

    });

    actionControls[1].addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (actionControls[1].isPressed()) {
                updateControls(1);
            }
        }

    });

    actionControls[2].addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (actionControls[2].isPressed()) {
                updateControls(2);
            }
        }

    });

    actionControls[3].addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (actionControls[3].isPressed()) {
                updateControls(3);
            }
        }

    });

    actionControls[4].addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (actionControls[4].isPressed()) {
                updateControls(4);
            }
        }
    });

    // Reset settings button
    resetSettingsButton = new TextButton("Reset Settings", skin);
    resetSettingsButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (resetSettingsButton.isPressed()) {
                game.save.resetSettings();
                musicSlider.setValue(game.save.getMusicLevel());
                resetActionControlsLabels();
            }
        }
    });

    // Reset save button.
    resetSaveButton = new TextButton("Reset Save", skin);
    resetSaveButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (resetSaveButton.isPressed()) {
                game.save.resetSave();
            }
        }
    });

    backButton = new TextButton("Back", skin);

}

From source file:ca.hiphiparray.amazingmaze.SplashScreen.java

License:Open Source License

/**
 * Create the splash screen./*  w  w  w .  j a va  2 s.co  m*/
 *
 * @param game the {@link AmazingMazeGame} instance that is managing this screen.
 */
public SplashScreen(final AmazingMazeGame game) {
    this.game = game;
    this.stage = new Stage(new ScreenViewport(), game.batch);

    Table table = new Table();
    table.setFillParent(true);
    table.center();
    stage.addActor(table);

    logo = new Image(this.game.assets.manager.get(Assets.COMPANY_LOGO, Texture.class));
    logo.addAction(Actions.sequence(Actions.alpha(0), Actions.delay(1f), Actions.fadeIn(1f), Actions.delay(1f),
            Actions.fadeOut(1f)));

    table.add(logo);
}