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

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

Introduction

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

Prototype

public Cell row() 

Source Link

Document

Indicates that subsequent cells should be added to a new row and returns the cell values that will be used as the defaults for all cells in the new row.

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);// w w w  . j a va 2s  .  c o m
    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);//from  www  . j  a va 2  s .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:at.highstreeto.xnllayoutparser.element.RowParser.java

License:Apache License

@Override
public Actor load(Element element, LayoutParserContext context) throws LayoutParseException {
    Table table = (Table) context.getActorByElement(element.getParent());
    for (int i = 0; i < element.getChildCount(); i++) {
        Element child = element.getChild(i);
        context.getParsers().getParserByElementName(child).load(child, context);
    }//from   w ww .j av  a2  s.com
    table.row();
    return null;
}

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

public void showPlayersView() {
    this.playerMenu.clear();

    TextButton btExit = new TextButton("Oke", skin);
    btExit.addListener(new ClickListener() {
        @Override/*from w  ww .  ja v a 2 s  . co m*/
        public void clicked(InputEvent event, float x, float y) {
            getSession().setPlayerMenuShowing(false);
            playerMenu.hide();
        }
    });

    this.playerMenu.add(btExit);

    Table scrollTable = new Table(skin);

    ArrayList<String> people = new ArrayList<>();
    PacketGetKickInformation packetGetKickInfo = new PacketGetKickInformation();
    Client.getInstance().send(packetGetKickInfo);
    people.addAll(packetGetKickInfo.getResult());

    for (String person : people) {
        String[] peopleResult = person.split(" ");

        TextButton bKick = new TextButton("Kick", skin);
        bKick.addListener(new ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                PacketSetKickInformation packetKick = new PacketSetKickInformation(
                        UUID.fromString(peopleResult[4]), null);
                Client.getInstance().send(packetKick);

                PacketGetKickInformation packetKickInfo = new PacketGetKickInformation();
                Client.getInstance().send(packetKickInfo);
                people.clear();
                people.addAll(packetKickInfo.getResult());
            }
        });

        scrollTable.add(peopleResult[0]);
        scrollTable.columnDefaults(0);
        scrollTable.add(bKick);
        scrollTable.columnDefaults(1);
        scrollTable.add(peopleResult[1] + "/" + peopleResult[2]);
        scrollTable.columnDefaults(2);
        scrollTable.row();

        if (peopleResult[3].equals("true")) {
            bKick.setDisabled(true);
            bKick.setTouchable(Touchable.disabled);
            bKick.setColor(255, 0, 0, 100);
        }
    }

    playerMenu.add(scrollTable);

    this.playerMenu.show(stage);
    getSession().showPlayerMenu();
}

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

public HighscoreScreen(Game game, boolean top10HighscoreReached) {
    super(game);/*from w  w  w.j  a  v a 2s. com*/

    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: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);//  w w w.  j a  v a 2  s.  c om
    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.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  a v  a 2 s  .c om
    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);//from  w  w w.  j a  v a  2  s. 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:ch.coldpixel.mario.Scenes.Hud.java

public Hud(SpriteBatch sb) {
    worldTimer = 300;//from  w  w w  .j  ava2s. c  om
    timeCount = 0;
    score = 0;

    viewport = new FitViewport(MarioBros.V_WIDTH, MarioBros.V_HEIGHT, new OrthographicCamera());
    stage = new Stage(viewport, sb);

    Table table = new Table();
    table.top(); //Top of our Stage
    table.setFillParent(true); //Table = size of our stage

    countdownLabel = new Label(String.format("%03d", worldTimer),
            new Label.LabelStyle(new BitmapFont(), Color.WHITE));//%03d = how many numbers, d=int,BitmapFont = Graphic Font, not regular Font
    scoreLabel = new Label(String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    timeLabel = new Label("TIME", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    levelLabel = new Label("1-1", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    worldLabel = new Label("WORLD", new Label.LabelStyle(new BitmapFont(), Color.WHITE));
    marioLabel = new Label("MARIO", new Label.LabelStyle(new BitmapFont(), Color.WHITE));

    table.add(marioLabel).expandX().padTop(10); //expandX = shares width with all elements, ex: 3 elements, each takes 1/3
    table.add(worldLabel).expandX().padTop(10);
    table.add(timeLabel).expandX().padTop(10);
    table.row();//New row
    table.add(scoreLabel).expandX();
    table.add(levelLabel).expandX();
    table.add(countdownLabel).expandX();

    stage.addActor(table);//Add table to Stage

}

From source file:com.ahsgaming.superrummy.screens.MainMenuScreen.java

License:Apache License

@Override
public void resize(int width, int height) {
    super.resize(width, height);

    Skin skin = getSkin();//from w ww. j  av  a  2s .c o  m

    TextButton btnNewGame = new TextButton("Single Player", skin);
    btnNewGame.setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
    btnNewGame.addListener(new ClickListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            Gdx.app.log(RummyGame.LOG, "btnNewGame touched");
        }
    });

    TextButton btnJoinMPGame = new TextButton("Multiplayer", skin);
    btnJoinMPGame.setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
    btnJoinMPGame.addListener(new ClickListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            Gdx.app.log(RummyGame.LOG, "btnJoinMPGame touched");
        }
    });

    TextButton btnOptions = new TextButton("Options", skin);
    btnOptions.setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
    btnOptions.addListener(new ClickListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            Gdx.app.log(RummyGame.LOG, "btnOptions touched");
        }
    });

    TextButton btnExit = new TextButton("Exit", skin);
    btnExit.setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
    btnExit.addListener(new ClickListener() {
        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            Gdx.app.log(RummyGame.LOG, "btnExit touched");
        }
    });

    Table table = new Table(skin);
    table.setFillParent(true);
    stage.addActor(table);
    table.add("Valley of Bones", "medium-font", new Color(1, 1, 1, 1)).spaceBottom(50f).colspan(2);

    table.row();

    table.add(btnNewGame).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().fill().spaceBottom(BUTTON_SPACING)
            .colspan(2);

    table.row();

    table.add(btnJoinMPGame).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().fill().spaceBottom(BUTTON_SPACING)
            .colspan(2);

    table.row();

    table.add(btnOptions).size(BUTTON_WIDTH, BUTTON_HEIGHT).uniform().fill().spaceBottom(BUTTON_SPACING)
            .colspan(2);

    table.row();

    table.add(btnExit).uniform().size(BUTTON_WIDTH, BUTTON_HEIGHT).spaceBottom(BUTTON_SPACING).colspan(2);

    table.row();
}