Example usage for com.badlogic.gdx.scenes.scene2d.ui Table Table

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Table Table

Introduction

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

Prototype

public Table() 

Source Link

Usage

From source file:Credits.java

License:Apache License

public Credits() {
    Sink.setBackground("title");
    Table grid = new Table();
    grid.setSize(Sink.targetWidth, Sink.targetHeight);
    grid.setFillParent(true);/*  www.  ja v  a  2 s.c om*/
    grid.setPosition(0, 0);
    grid.top().left();
    grid.center();
    grid.setPosition(0, -250);
    grid.addAction(Actions.moveTo(0, 110, 2.0f));
    grid.center();
    /*   ________________________
    * |_______Credits__________|
    * |        |            |
    * |        |            |
    * |        |            |
    * |__________|_____________|
    * |_________Back___________|
    */
    TextButton title = new TextButton("Credits", Asset.skin);
    TextButton back = new TextButton("Back", Asset.skin);
    back.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            Sink.setScene("Menu");
        }
    });
    grid.add(title).size(200, 75);
    grid.row();
    grid.add(back).size(200, 75).center();
    Sink.addActor(grid);
}

From source file:Levels.java

License:Apache License

public Levels() {
    Table grid = new Table();
    grid.setSize(Sink.targetWidth, Sink.targetHeight);
    grid.setFillParent(true);/* ww  w. j a  v  a 2s .c o  m*/
    grid.setPosition(0, 0);
    grid.top().left();
    grid.center();
    grid.setPosition(-999, 0);
    grid.addAction(Actions.moveTo(0, 0, 0.3f));
    grid.top().left().pad(10, 10, 10, 10);
    /*   _____________________
     * | [1] [2] [3] [4] [5] |
     * |                  | 
     * |                  |
     * |                 |
     * |_____________________|
    */

    for (int i = 0; i < maxLevel; i++) {
        final int index = i;
        TextButton btn = new TextButton("" + (i + 1), Asset.skin);
        if (i > Config.levels() - 0)
            btn.setVisible(false);
        if (i % 5 == 0)
            grid.row();
        grid.add(btn).size(100, 100).pad(5, 0, 0, 0).expandX();
        btn.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                super.clicked(event, x, y);
                Game.currentLevel = index;
                Sink.setScene("Game");
            }
        });
    }
    Sink.addActor(grid);
}

From source file:Options.java

License:Apache License

public Options() {
    Sink.setBackground("title");
    Sink.transitionDownToUp();/*from  w  w  w . jav a  2  s.  co m*/
    grid = new Table();
    grid.setSize(Sink.targetWidth, Sink.targetHeight);
    grid.setFillParent(true);
    grid.setPosition(0, 0);
    grid.top().left();
    grid.center();
    float yoffset = Sink.targetHeight - 80;
    float xcenter = Sink.targetWidth / 2;

    /*   ________________________
     * |_______Options__________|
     * |        |            |
     * |        |            |
     * |        |            |
     * |__________|_____________|
     * |_________Back___________|
    */
    TextButton title = new TextButton("Options", Asset.skin);
    title.setSize(200, 75);
    TextButton back = new TextButton("Back", Asset.skin);
    back.setSize(200, 75);
    back.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            Sink.setScene("Menu");
        }
    });

    CheckBox soundbtn = new CheckBox("  Sound ", Asset.skin);
    soundbtn.setChecked(Config.isSound);

    CheckBox musicbtn = new CheckBox("  Music ", Asset.skin);
    musicbtn.setChecked(Config.isMusic);

    CheckBox battbtn = new CheckBox("  Battle ", Asset.skin);
    battbtn.setChecked(Config.isBattleEnabled());

    CheckBox semibtn = new CheckBox(" Semi-Auto ", Asset.skin);
    semibtn.setChecked(Config.isSemiAutomatic());

    CheckBox panbtn = new CheckBox("  PanScroll ", Asset.skin);
    panbtn.setChecked(Config.usePan);

    CheckBox dragbtn = new CheckBox("  DragScroll ", Asset.skin);
    dragbtn.setChecked(Config.useDrag);

    CheckBox keybtn = new CheckBox("  UseKeyboard ", Asset.skin);
    keybtn.setChecked(Config.useKeyboard);

    Slider musicSlider = new Slider(0f, 1f, 0.1f, false, Asset.skin);
    Slider soundSlider = new Slider(0f, 1f, 0.1f, false, Asset.skin);

    Sink.addActor(title, xcenter - title.getWidth() + 30, yoffset);
    Sink.addActor(musicbtn, xcenter - musicbtn.getWidth(), yoffset - 60);
    Sink.addActor(musicSlider, xcenter + 30, yoffset - 60);
    Sink.addActor(soundbtn, xcenter - soundbtn.getWidth(), yoffset - 90);
    Sink.addActor(soundSlider, xcenter + 30, yoffset - 90);

    Sink.addActor(battbtn, xcenter - battbtn.getWidth(), yoffset - 120);
    Sink.addActor(panbtn, xcenter + 30, yoffset - 120);

    Sink.addActor(semibtn, xcenter - semibtn.getWidth(), yoffset - 150);
    Sink.addActor(dragbtn, xcenter + 30, yoffset - 150);
    Sink.addActor(dragbtn, xcenter + 30, yoffset - 180);

    Sink.addActor(back, xcenter - back.getWidth() + 30, 20);
}

From source file:at.highstreeto.xnllayoutparser.element.TableParser.java

License:Apache License

@Override
public Actor load(Element element, LayoutParserContext context) throws LayoutParseException {
    Table table = new Table();

    if (element.getAttributes().containsKey("fillParent")) {
        table.setFillParent(element.getBooleanAttribute("fillParent"));
    }//from  w  w w. ja  v  a 2  s  .  c o  m
    if (element.getAttributes().containsKey("debug")) {
        String[] parts = element.getAttribute("debug").split(" ");
        for (String i : parts) {
            if ("cell".equals(i)) {
                table.debugCell();
            } else if ("table".equals(i)) {
                table.debugTable();
            }
        }
    }
    // Combination of c (Center), t (Top), b (Bottom), l (Left), r (Right)
    if (element.getAttributes().containsKey("align")) {
        String[] parts = element.getAttribute("align").split(" ");
        for (String i : parts) {
            if ("c".equals(i)) {
                table.center();
            } else if ("t".equals(i)) {
                table.top();
            } else if ("b".equals(i)) {
                table.bottom();
            } else if ("l".equals(i)) {
                table.left();
            } else if ("r".equals(i)) {
                table.right();
            }
        }
    }

    context.addActor(table, element);
    ElementParserHelper.setActorName(element, table);

    for (int i = 0; i < element.getChildCount(); i++) {
        Element child = element.getChild(i);
        context.getParsers().getParserByElementName(child).load(child, context);
    }
    return table;
}

From source file:ateamproject.kezuino.com.github.render.screens.HighscoreScreen.java

public HighscoreScreen(Game game, boolean top10HighscoreReached) {
    super(game);//w w w  .java2 s  . c  o  m

    TextButton btnBack = new TextButton("Terug", skin);
    btnBack.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            if (top10HighscoreReached) {
                game.setScreen(new CreditsScreen(game));
            } else {
                game.setScreen(new MainScreen(game));
            }
        }
    });
    float x = 240;
    float y = stage.getHeight() / 4;
    btnBack.setSize(200, 40);
    btnBack.setPosition(stage.getWidth() / 2 - btnBack.getWidth() / 2,
            stage.getHeight() / 4 - btnBack.getHeight() / 2);

    Label lblTitle = new Label("Highscore", skin);
    if (top10HighscoreReached) {
        lblTitle = new Label("Gefeliciteerd met een top 10 plek!", skin);
        btnBack.setText("Haal mijn prijs op");
    }
    lblTitle.setColor(Color.YELLOW);
    lblTitle.setPosition(stage.getWidth() / 2 - lblTitle.getWidth() / 2, stage.getHeight() - 50);

    PacketGetHighscores packet = new PacketGetHighscores(Client.getInstance().getId());
    Client.getInstance().send(packet);

    Table table = new Table();
    table.setSkin(skin);

    int rankNr = 0;

    for (Map.Entry<String, Integer> entry : packet.getResult().entrySet()) {
        rankNr++;
        table.add(new Label(Integer.toString(rankNr), skin)).padRight(50);
        table.add(new Label(entry.getKey(), skin)).padRight(50);
        table.add(new Label(Integer.toString(entry.getValue()), skin));
        table.row();
    }

    table.setPosition(stage.getWidth() / 2 - table.getWidth() / 2, stage.getHeight() - 190);

    stage.addActor(btnBack);
    stage.addActor(lblTitle);
    stage.addActor(table);

    backgroundMusic = Assets.getMusicStream("menu.mp3");
}

From source file:awakening.view.menu.WaitingRoomClient.java

License:Apache License

/**
 * Constructor/*from   w  w w .jav  a 2  s.  com*/
 * 
 * @param game Tower Awakening's Game
 * @param sound Main menu's music
 * @param effect Button's effect
 */
public WaitingRoomClient(TAGame game, Music sound, Sound effect) {
    this.game = game;
    this.sound = sound;
    this.effect = effect;

    try {
        socket = new Socket(InetAddress.getByName(null), 1134);
        input = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        output = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())), true);
    } catch (Exception e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    th1 = new Thread(new Runnable() {
        @Override
        public void run() {
            try {
                while (true) {
                    String messagePlayer = input.readLine();
                    if (messagePlayer != null) {
                        TextArea t = new TextArea(messagePlayer, skin);
                        t.setTouchable(Touchable.disabled);
                        chatBox.row();
                        chatBox.add(t).height(75).width(500);
                    }
                }
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
    th1.start();

    stage = new Stage();

    try {
        if (game.getLanguage().equals("ENGLISH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]);
        } else if (game.getLanguage().equals("FRENCH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]);
        } else if (game.getLanguage().equals("ITALIAN")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]);
        } else {
            language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]);
        }
    } catch (java.util.MissingResourceException e) {
        System.out.println("yolo");
    }

    ///Viewport
    camera = new OrthographicCamera();
    view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera);

    ///Background
    background = new Texture(Gdx.files.internal("img/menu/Background-2.png"));
    batch = new SpriteBatch();

    ///Skin
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    ///Title
    title = new Label(language.getString("label_waiting_room"), skin);

    ///Widgets Background
    widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/window_selection.png")));
    widgetsBackground.setSize(Gdx.app.getGraphics().getWidth() - Gdx.app.getGraphics().getWidth() / 8,
            Gdx.app.getGraphics().getHeight() - Gdx.app.getGraphics().getHeight() / 8);

    ///Back Button
    btnBack = new TextButton(language.getString("button_back"), skin);

    ///ChatBox
    chatBox = new Table();
    scroll = new ScrollPane(chatBox);
    scroll.setForceScroll(false, true);
    scroll.setFlickScroll(true);
    scroll.setOverscroll(false, false);

    ///Message
    message = new TextField("", skin);
    btnSend = new TextButton(language.getString("button_send"), skin);

}

From source file:awakening.view.menu.WaitingRoomServer.java

License:Apache License

/**
 * Constructor//w  ww .  j  a v a2 s  . c  o  m
 * 
 * @param game Tower Awakening's Game
 * @param sound Main menu's music
 * @param effect Button's effect
 */
public WaitingRoomServer(TAGame game, Music sound, Sound effect) {
    this.game = game;
    this.sound = sound;
    this.effect = effect;

    try {
        serverSocket = new ServerSocket(portEcoute);
    } catch (IOException e) {
        System.err.println("Creation de la socket impossible : " + e);
        System.exit(-1);
    }

    stage = new Stage();

    try {
        if (game.getLanguage().equals("ENGLISH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_en_EN", locales[0]);
        } else if (game.getLanguage().equals("FRENCH")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_fr_FR", locales[1]);
        } else if (game.getLanguage().equals("ITALIAN")) {
            language = ResourceBundle.getBundle("awakening.view.menu.res_it_IT", locales[2]);
        } else {
            language = ResourceBundle.getBundle("awakening.view.menu.res", locales[0]);
        }
    } catch (java.util.MissingResourceException e) {
        System.out.println("yolo");
    }

    ///Viewport
    camera = new OrthographicCamera();
    view = new StretchViewport(Gdx.app.getGraphics().getWidth(), Gdx.app.getGraphics().getWidth(), camera);

    ///Background
    background = new Texture(Gdx.files.internal("img/menu/Background-2.png"));
    batch = new SpriteBatch();

    ///Skin
    skin = new Skin(Gdx.files.internal("uiskin.json"));

    ///Title
    title = new Label(language.getString("label_waiting_room"), skin);

    ///Widgets Background
    widgetsBackground = new Image(new Texture(Gdx.files.internal("img/widget/window_selection.png")));
    widgetsBackground.setSize(Gdx.app.getGraphics().getWidth() - Gdx.app.getGraphics().getWidth() / 8,
            Gdx.app.getGraphics().getHeight() - Gdx.app.getGraphics().getHeight() / 8);

    ///Back Button
    btnBack = new TextButton(language.getString("button_back"), skin);

    ///ChatBox
    chatBox = new Table();
    scroll = new ScrollPane(chatBox);
    scroll.setForceScroll(false, true);
    scroll.setFlickScroll(true);
    scroll.setOverscroll(false, false);

    ///Message
    message = new TextField("", skin);
    btnSend = new TextButton(language.getString("button_send"), skin);

    ///Start Button
    btnStart = new TextButton(language.getString("button_start"), skin);

}

From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.MenuScreen.java

License:Open Source License

@Override
public void show() {
    super.show();

    // Set Background

    addBackGroundShift("GdxMenus/main/mainmenubg.jpg");

    // Add Button image

    addBackGround("GdxMenus/main/mainmenubuttons.png");

    // Create the 2 Bouboules out of the screen

    final Image imgBoubouleR = addImage("GdxMenus/main/boubouleright.png", GlobalSettings.APPWIDTH, 1f);
    final Image imgBoubouleL = addImage("GdxMenus/main/boubouleleft.png", -GlobalSettings.APPWIDTH, 1f);

    // add action on the bouboule
    final ActionBouboul actionbouL = new ActionBouboul(false);
    this.stage.addAction(actionbouL);
    actionbouL.setActor(imgBoubouleL);//from w ww.j ava2  s .  co m

    final ActionBouboul actionbouR = new ActionBouboul(true);
    this.stage.addAction(actionbouR);
    actionbouR.setActor(imgBoubouleR);

    // add the title
    title = new Label("BOUBOULE", getSkin(), "darktimes-font", new Color(.388f, .733f, .984f, 1f));
    title.setAlignment(Align.center); // center
    title.setWidth(GlobalSettings.APPWIDTH);
    // title.setColor(.2f, .7098f, .898f, 1f);  // android color

    // add the title in a table in order to rotate it.
    Table tableTitle = new Table();
    tableTitle.add(title);
    tableTitle.setTransform(true);
    tableTitle.setWidth(GlobalSettings.APPWIDTH); // all the width
    tableTitle.setX(0);
    tableTitle.setY((int) (1050 * GlobalSettings.HD) - GlobalSettings.SHIFT_BG_HEIGHT / 2);
    tableTitle.setOrigin(GlobalSettings.APPWIDTH / 2, tableTitle.getHeight() / 2); // at the center
    stage.addActor(tableTitle);

    // add action on the title
    final ActionTitle actiontitle = new ActionTitle();
    this.stage.addAction(actiontitle);
    actiontitle.setActor(tableTitle);

    // Add 5 button transparent
    Button playButton, paramButton, scoreButton, boubouleButton, titleButton;
    if (GlobalSettings.ISHD) {
        playButton = createButton("transparent", 690, 250, 312, 1150);
        paramButton = createButton("transparent", 690, 250, 312, 887);
        scoreButton = createButton("transparent", 690, 250, 312, 615);
        boubouleButton = createButton("transparent", 1000, 600, 200, 0);
        titleButton = createButton("transparent", 1000, 1000, 200, 1450);
    } else {
        playButton = createButton("transparent", 430, 160, 200, 725);
        paramButton = createButton("transparent", 430, 160, 200, 555);
        scoreButton = createButton("transparent", 430, 160, 200, 385);
        boubouleButton = createButton("transparent", 500, 350, 200, 0);
        titleButton = createButton("transparent", 500, 500, 200, 885);
    }

    // Listener for the button
    playButton.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            if (GlobalSettings.GAME.isPlayingGame())
                setScreenWithFading(null);
            else
                setScreenWithFading(new WorldScreen());
        }
    });

    paramButton.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            setScreenWithFading(new ParamScreen());
        }
    });

    scoreButton.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {

            if (GlobalSettings.GAMECENTER != null) {
                GlobalSettings.GAMECENTER.showLeaderboard();
            } else {
                Dialog dialog = new Dialog("  HighScore  ", getSkin(), "default") {
                    // improved default skin?
                    // protected void result(Object object) {} // Just hide the dialog
                }.text("\n" + getHighScoreText() + " ").button("     Close     ", null).show(stage);
                dialog.setX((GlobalSettings.APPWIDTH - dialog.getWidth()) / 2);
            }
        }
    });

    boubouleButton.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            final ActionBouboul actionbouL = new ActionBouboul(false);
            actionbouL.init();
            stage.addAction(actionbouL);
            actionbouL.setActor(imgBoubouleL);

            final ActionBouboul actionbouR = new ActionBouboul(true);
            actionbouR.init();
            stage.addAction(actionbouR);
            actionbouR.setActor(imgBoubouleR);
        }
    });

    titleButton.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            actiontitle.switchName();
        }
    });
}

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

License:Open Source License

/**
 * The constructor for ContinueScreen./*from  ww w . j av a 2s. c  om*/
 *
 * @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.CreditsScreen.java

License:Open Source License

/**
 * Instantiate the stage and its actors for the credits screen.
 * Add all actors to the stage./*from ww  w  . j ava 2 s. c om*/
 */
private void setupComponents() {
    stage = new Stage();
    table = new Table();
    table.top();
    table.setFillParent(true);
    stage.addActor(table);

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

    header = new Label("", game.assets.skin, Assets.SERIF_HEADER_STYLE);
    codeGroup = setupCreditsLabel(CODE, Assets.CREDITS_CONTENTS);
    artGroup = setupCreditsLabel(ART, Assets.CREDITS_CONTENTS);
    storyGroup = setupCreditsLabel(STORY, Assets.CREDITS_CONTENTS);
    musicGroup = setupCreditsLabel(MUSIC, Assets.SMALL_CREDITS_CONTENTS);
    thanksGroup = setupCreditsLabel(THANKS, Assets.CREDITS_CONTENTS);

    companyLogo = new Image(game.assets.manager.get(Assets.COMPANY_LOGO, Texture.class));
}