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

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

Introduction

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

Prototype

public Table padRight(float padRight) 

Source Link

Document

Padding at the right edge of the table.

Usage

From source file:com.peppercarrot.runninggame.stages.CreditsTable.java

public CreditsTable() {
    super();/*from  w w  w  . j  a  va  2s  .  c om*/

    Table content = new Table(Assets.I.skin);
    ScrollPane scroll = new ScrollPane(content, Assets.I.skin);
    scroll.setScrollingDisabled(true, false);
    scroll.setFadeScrollBars(false);

    top();
    padTop(30);
    padBottom(60);
    int paddingScrollPane = 10;
    content.padLeft(paddingScrollPane);
    content.padRight(paddingScrollPane);
    Texture texture;
    texture = new Texture(Gdx.files.internal("logo_original_webcomic.png"), true);
    texture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);
    Image originalLogo = new Image(texture);
    texture = new Texture(Gdx.files.internal("Pepper_And_Carrot_Running_Game.png"), true);
    texture.setFilter(TextureFilter.MipMapLinearNearest, TextureFilter.Nearest);
    Image gameLogo = new Image(texture);

    Label label1 = new Label(
            "This game is open-source and a derivative of universe of the webcomic"
                    + " Pepper&Carrot created by David Revoy and licensed under CC-BY 4.0",
            Assets.I.skin, "default");
    label1.setWrap(true);
    /*
    Label label2 = new Label("Visit original Pepper&Carrot website. (Link in this Version is deactivated)", Assets.I.skin, "default");
    label2.setWrap(true);
    */
    TextButton webComicLink = new TextButton("Visit original" + '\n' + "Pepper&Carrot" + '\n' + "website",
            Assets.I.skin);
    webComicLink.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            Gdx.net.openURI("http://www.peppercarrot.com/");
            event.cancel();
        }
    });

    TextButton gitHubLink = new TextButton("This game" + '\n' + "can be found" + '\n' + "on GitHub",
            Assets.I.skin);
    gitHubLink.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            Gdx.net.openURI("https://github.com/WinterLicht/PepperAndCarrotRunningGame");
            event.cancel();
        }
    });
    /*
    Label label3 = new Label("This game is open source and can be found on GitHub. (Link in this Version is deactivated)", Assets.I.skin, "default");
    label3.setWrap(true);
    */
    content.add(label1).width(700).colspan(2);
    content.row();
    content.add(webComicLink).width(280).padTop(30).left();
    content.add(originalLogo).width(originalLogo.getWidth()).padTop(30).right();
    content.row();
    content.add(gitHubLink).width(280).padTop(30).left();
    content.add(gameLogo).width(gameLogo.getWidth()).padTop(30).right();
    content.row();

    add(scroll);
}

From source file:cs383.team1.input.ui.ItemsExtension.java

private Table statComp(String icn, Double i, double e1, double e2) {
    Table t;
    t = new Table();

    addIcon(icn, t);/*from  www  .ja  v  a  2 s .  c om*/
    t.left().add(new Label(i.toString(), skin)).left().fillX().expandX().row();
    t.add(cmpStat(e1, i)).colspan(2).right().expandX();
    t.row();
    t.add(cmpStat(e2, i)).colspan(2).right().expandX();

    t.padRight(15);

    return t;
}

From source file:cs383.team1.input.ui.ItemsExtension.java

private Table statComp(String icn, Double i, double e1) {
    Table t;
    t = new Table();

    addIcon(icn, t);//from  w  w w  .j  ava 2 s.  c om
    t.left().add(new Label(i.toString(), skin)).left().fillX().expandX().row();
    t.add(cmpStat(e1, i)).colspan(2).right().expandX();

    t.padRight(15);

    return t;
}

From source file:gui.screen.MainPlayerHud.java

public MainPlayerHud(final EntityManager entityManager, Game game, Server server, Client client,
        final MapLoader map, OrthographicCamera camera) {
    super(game, client, server);

    deathMessageArray = new ArrayList<>();
    textMessageArray = new ArrayList<>();

    //Initialise Objects
    this.stage = new Stage(new StretchViewport(Constants.SCREENWIDTH, Constants.SCREENHEIGHT));
    this.stack = new Stack(); //A container in wich you can place multiple widgets to "stack" them
    this.touchTable.setSize(stage.getWidth(), stage.getHeight());
    this.camera = camera;
    touchTable.setTouchable(Touchable.enabled);
    stage.addActor(touchTable);/*from  ww w .  j a v  a 2 s. c  om*/
    this.entityManager = entityManager;

    //Initialise Font
    this.generator = new FreeTypeFontGenerator(Gdx.files.internal("fonts/lunchtime-doubly-so/lunchds.ttf"));
    this.parameter = new FreeTypeFontParameter();
    parameter.size = 15;

    //Table settings
    Table backgroundTable = new Table();
    backgroundTable.top();
    backgroundTable.setFillParent(true);

    //Table settings 2
    Table foregroundTable = new Table();
    foregroundTable.top();
    foregroundTable.setFillParent(true);

    /**------------------------EXIT DIALOG------------------------**/
    exitDialog = new Dialog("Confirm exit", TextureManager.skin) {
        @Override
        public void result(Object obj) {
            boolean result = (boolean) obj;

            if (result == true) {
                //Stop music
                AudioManager.getCurrentMusic().stop();

                quitGame();
            } else {
                Gdx.input.setCursorCatched(true);
            }
        }
    };
    exitDialog.text("Are you sure you want to quit?");
    exitDialog.button("Yes", true); //sends "true" as the result
    exitDialog.button("No", false); //sends "false" as the result

    if (Constants.ISRUNNINGONSMARTPHONE && Constants.TOUCHSCREEN) {
        touchTable.addListener(new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float x, float y, int pointer, int buttonCode) {

                Player player = entityManager.getPlayerManager().getCurrentPlayerObject();

                if (player != null) {
                    // Calculate correct world position
                    ThinGridCoordinates aim = new ThinGridCoordinates(
                            player.getPosition().getX() + (x - touchTable.getWidth() / 2f),
                            player.getPosition().getY() + (y - touchTable.getHeight() / 2f));
                    aim = new ThinGridCoordinates(aim.getX() - (x - touchTable.getWidth() / 2f) / 3.5f,
                            aim.getY() - (y - touchTable.getHeight() / 2f) / 3.5f);

                    // Change to block center
                    ThinGridCoordinates blockCenter = new ThinGridCoordinates(new MapCellCoordinates(aim));
                    aim.setX(blockCenter.getX() + (Constants.MAPTEXTUREWIDTH - Constants.PLAYERWIDTH) / 2);
                    aim.setY(
                            blockCenter.getY() + (Constants.MAPTEXTUREHEIGHT - Constants.PLAYERHEIGHT / 4) / 2);

                    goToCoordiantes = aim;
                }

                return true;
            }

            @Override
            public void touchDragged(InputEvent event, float x, float y, int pointer) {
                Player player = entityManager.getPlayerManager().getCurrentPlayerObject();

                if (player != null) {
                    // Calculate correct world position
                    ThinGridCoordinates aim = new ThinGridCoordinates(
                            player.getPosition().getX() + (x - touchTable.getWidth() / 2f),
                            player.getPosition().getY() + (y - touchTable.getHeight() / 2f));
                    aim = new ThinGridCoordinates(aim.getX() - (x - touchTable.getWidth() / 2f) / 3.5f,
                            aim.getY() - (y - touchTable.getHeight() / 2f) / 3.5f);

                    // Change to block center
                    ThinGridCoordinates blockCenter = new ThinGridCoordinates(new MapCellCoordinates(aim));
                    aim.setX(blockCenter.getX() + (Constants.MAPTEXTUREWIDTH - Constants.PLAYERWIDTH) / 2);
                    aim.setY(
                            blockCenter.getY() + (Constants.MAPTEXTUREHEIGHT - Constants.PLAYERHEIGHT / 4) / 2);

                    goToCoordiantes = aim;
                }

            }

            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

            }

        });
    }

    /*-------------------------MOVEMENT TOUCHPAD--------------------------*/
    if (Constants.ISRUNNINGONSMARTPHONE && Constants.TOUCHPAD) {
        //Create a touchpad skin
        touchpadSkin = new Skin();
        //Set background image
        touchpadSkin.add("touchBackground", new Texture("hud/touchBackground.png"));
        //Set knob image
        touchpadSkin.add("touchKnob", new Texture("hud/touchKnob.png"));
        //Create TouchPad Style
        touchpadStyle = new Touchpad.TouchpadStyle();
        //Create Drawable's from TouchPad skin
        touchBackground = touchpadSkin.getDrawable("touchBackground");
        touchKnob = touchpadSkin.getDrawable("touchKnob");
        //Apply the Drawables to the TouchPad Style
        touchpadStyle.background = touchBackground;
        touchpadStyle.knob = touchKnob;
        //Create new TouchPad with the created style
        touchpad = new Touchpad(10, touchpadStyle);
        //setBounds(x,y,width,height)
        touchpad.setBounds(15, 15, 150, 150);

        stage.addActor(touchpad);

        touchpad.addListener(new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float screenX, float screenY, int pointer,
                    int buttonCode) {

                return true;
            }

            @Override
            public void touchDragged(InputEvent event, float screenX, float screenY, int pointer) {
                ThinGridCoordinates aim = null;

                Player player = entityManager.getPlayerManager().getCurrentPlayerObject();

                if (player != null) {

                    // Left
                    if (touchpad.getKnobPercentX() < -0.5) {
                        float x = 370;
                        float y = 250;

                        // Calculate correct world position
                        aim = new ThinGridCoordinates(
                                player.getPosition().getX() + (x - touchTable.getWidth() / 2f),
                                player.getPosition().getY() + (y - touchTable.getHeight() / 2f));
                        aim = new ThinGridCoordinates(aim.getX() - (x - touchTable.getWidth() / 2f) / 3.5f,
                                aim.getY() - (y - touchTable.getHeight() / 2f) / 3.5f);

                        //Right
                    } else if (touchpad.getKnobPercentX() > 0.5) {
                        float x = 460;
                        float y = 250;

                        // Calculate correct world position
                        aim = new ThinGridCoordinates(
                                player.getPosition().getX() + (x - touchTable.getWidth() / 2f),
                                player.getPosition().getY() + (y - touchTable.getHeight() / 2f));
                        aim = new ThinGridCoordinates(aim.getX() - (x - touchTable.getWidth() / 2f) / 3.5f,
                                aim.getY() - (y - touchTable.getHeight() / 2f) / 3.5f);
                    }

                    // Down
                    if (touchpad.getKnobPercentY() < -0.5) {
                        float x = 415;
                        float y = 200;

                        // Calculate correct world position
                        aim = new ThinGridCoordinates(
                                player.getPosition().getX() + (x - touchTable.getWidth() / 2f),
                                player.getPosition().getY() + (y - touchTable.getHeight() / 2f));
                        aim = new ThinGridCoordinates(aim.getX() - (x - touchTable.getWidth() / 2f) / 3.5f,
                                aim.getY() - (y - touchTable.getHeight() / 2f) / 3.5f);

                        // Up
                    } else if (touchpad.getKnobPercentY() > 0.5) {

                        float x = 415;
                        float y = 300;

                        // Calculate correct world position
                        aim = new ThinGridCoordinates(
                                player.getPosition().getX() + (x - touchTable.getWidth() / 2f),
                                player.getPosition().getY() + (y - touchTable.getHeight() / 2f));
                        aim = new ThinGridCoordinates(aim.getX() - (x - touchTable.getWidth() / 2f) / 3.5f,
                                aim.getY() - (y - touchTable.getHeight() / 2f) / 3.5f);
                    }

                    if (aim != null) {
                        // Change to block center
                        ThinGridCoordinates blockCenter = new ThinGridCoordinates(new MapCellCoordinates(aim));
                        aim.setX(blockCenter.getX() + (Constants.MAPTEXTUREWIDTH - Constants.PLAYERWIDTH) / 2);
                        aim.setY(blockCenter.getY()
                                + (Constants.MAPTEXTUREHEIGHT - Constants.PLAYERHEIGHT / 4) / 2);
                    }

                    goToCoordiantes = aim;
                }
            }

            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                InputHandler.setAnyKey(false);
                InputHandler.resetMovementKeys();

            }
        });
    }

    /*-------------------------ACTION TOUCHPAD--------------------------*/
    if (Constants.ISRUNNINGONSMARTPHONE) {
        Table table = new Table();
        table.setFillParent(true);
        table.right().bottom().toFront();

        /*-------------------------PLACE BOMB--------------------------*/
        placeBombButton.addListener(new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float screenX, float screenY, int pointer,
                    int buttonCode) {

                InputHandler.setAnyKey(true);
                InputHandler.setPlaceBombKey(true);

                return true;
            }

            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                InputHandler.setAnyKey(false);
                InputHandler.setPlaceBombKey(false);
            }

        });

        placeBombButton.setSize(100, 100);

        table.add(placeBombButton).size(placeBombButton.getWidth(), placeBombButton.getHeight()).padBottom(10)
                .padRight(10);

        stage.addActor(table);

        /*-------------------------TRIGGER REMOTE BUTTON--------------------------*/
        Table table1 = new Table();
        table1.right().bottom().toFront();

        triggerRemoteButton.addListener(new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float screenX, float screenY, int pointer,
                    int buttonCode) {

                InputHandler.setAnyKey(true);
                InputHandler.setRemoteKey(true);

                return true;
            }

            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                InputHandler.setAnyKey(false);
                InputHandler.setRemoteKey(false);
            }

        });

        triggerRemoteButton.setSize(60, 60);

        table1.add(triggerRemoteButton).size(triggerRemoteButton.getWidth(), triggerRemoteButton.getHeight());
        table1.setPosition(685, 80);
        stage.addActor(table1);

        /*-------------------------TELEPORT BUTTON--------------------------*/
        Table table2 = new Table();
        table1.right().bottom().toFront();

        teleportButton.addListener(new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float screenX, float screenY, int pointer,
                    int buttonCode) {

                InputHandler.setAnyKey(true);
                InputHandler.setTeleportKey(true);

                return true;
            }

            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
                InputHandler.setAnyKey(false);
                InputHandler.setTeleportKey(false);
            }

        });

        teleportButton.setSize(60, 60);

        table2.add(teleportButton).size(teleportButton.getWidth(), teleportButton.getHeight());
        table2.setPosition(Constants.SCREENWIDTH - 65, 155);
        stage.addActor(table2);
    }

    /*-------------------------RESIZE ELEMENTS IN HUD--------------------------*/
    if (Constants.ISRUNNINGONSMARTPHONE) {
        scaleCounterHud = 4; // Default 3
        scaleInventoryImg = 1.8f; // Default 1.5
        addToPositionX = 20; // Default -2
        scaleTextMessage = 6; // Default 5
        Constants.DEFAULTZOOM = 0.7f; // Default 1f
    }

    /*-------------------------GO BACK TO MENU BUTTON--------------------------*/
    if (Constants.ISRUNNINGONSMARTPHONE) {
        Table table = new Table();

        goToMenuButton.addListener(new InputListener() {
            @Override
            public boolean touchDown(InputEvent event, float screenX, float screenY, int pointer,
                    int buttonCode) {

                InputHandler.setAnyKey(true);
                InputHandler.setEscKey(true);

                return true;
            }

            @Override
            public void touchUp(InputEvent event, float x, float y, int pointer, int button) {

                InputHandler.setAnyKey(false);
                InputHandler.setEscKey(false);
            }
        });

        goToMenuButton.setSize(70, 70);

        table.add(goToMenuButton).size(goToMenuButton.getWidth(), goToMenuButton.getHeight());
        table.setSize(goToMenuButton.getWidth(), goToMenuButton.getHeight());
        table.padTop(40);
        table.padRight(40);
        table.setPosition(Constants.SCREENWIDTH - table.getWidth(), Constants.SCREENHEIGHT - table.getHeight());

        stage.addActor(table);
    }

    /*-------------------------SCREEN MESSAGE--------------------------*/
    Table messageLabel = new Table();
    messageLabel.setFillParent(true);
    messageLabel.right();

    parameter.size = 4 * (int) scaleTextMessage;
    deathMessageLabel = new Label("",
            new Label.LabelStyle(generator.generateFont(parameter), Color.valueOf("f7472c")));
    deathMessageLabel.setAlignment(Align.center);
    deathMessageLabel.setSize(200, 50);
    messageLabel.add(deathMessageLabel);

    textMessageLabel = new Label("", new Label.LabelStyle(generator.generateFont(parameter), Color.YELLOW));
    textMessageLabel.setAlignment(Align.center);
    textMessageLabel.setSize(200, 50);
    messageLabel.add(textMessageLabel);

    stage.addActor(messageLabel);

    /*-------------------------LIFE & COUNTER HUD--------------------------*/
    parameter.size = 5 * (int) scaleCounterHud;
    //Labels (textfields)
    bombCounterLabel = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.WHITE));
    coinCounterLabel = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.WHITE));
    speedCounterLabel = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.WHITE));
    rangeCounterLabel = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.WHITE));

    //Live & coins display image
    uiCounterImage = new Image(TextureManager.hudCounterFullLive);

    //Calculate image width (scaledCounterX) and image height (scaleY)
    float scaledCounterX = TextureManager.hudCounterFullLive.getWidth() * scaleCounterHud;
    float scaledCounterY = TextureManager.hudCounterFullLive.getHeight() * scaleCounterHud;

    //Add image to background messageLabel
    backgroundTable.add(uiCounterImage).width(scaledCounterX).height(scaledCounterY);

    //Add label to foreground messageLabel
    foregroundTable.row().expandX().padTop(8 * scaleCounterHud);
    foregroundTable.add(bombCounterLabel).padLeft(40 * scaleCounterHud);
    foregroundTable.add(coinCounterLabel).padLeft(16 * scaleCounterHud);
    foregroundTable.add(rangeCounterLabel).padLeft(13 * scaleCounterHud);
    foregroundTable.add(speedCounterLabel).padLeft(18 * scaleCounterHud);

    //Set container to the height of the image and position it on the top left
    stack.setWidth(scaledCounterX);
    stack.setHeight(scaledCounterY);
    stack.setPosition(0, 470 - scaledCounterY);

    //End messageLabel and container (stack)
    stack.add(backgroundTable);
    stack.add(foregroundTable);
    stage.addActor(stack);

    /*-------------------------BOMB INVENTORY HUD--------------------------*/

    // Inventory Image
    uiInventoryImage = new Image(TextureManager.hudInventoryHiglighted1);
    uiInventoryImage.setWidth(280 * scaleInventoryImg);// 1,5x bigger
    uiInventoryImage.setHeight(32 * scaleInventoryImg);
    uiInventoryImage.setPosition((Constants.SCREENWIDTH - uiInventoryImage.getWidth()) / 2 + addToPositionX, 5);
    stage.addActor(uiInventoryImage);

    // Price labels
    bombPrice1 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));
    bombPrice2 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));
    bombPrice3 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));
    bombPrice4 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));
    bombPrice5 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));
    bombPrice6 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));
    bombPrice7 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));
    bombPrice8 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));
    bombPrice9 = new Label("000", new Label.LabelStyle(generator.generateFont(parameter), Color.GOLD));

    Table pricesTable = new Table();
    pricesTable.setFillParent(true);

    //31x31
    pricesTable.add(bombPrice1).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);
    pricesTable.add(bombPrice2).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);
    pricesTable.add(bombPrice3).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);
    pricesTable.add(bombPrice4).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);
    pricesTable.add(bombPrice5).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);
    pricesTable.add(bombPrice6).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);
    pricesTable.add(bombPrice7).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);
    pricesTable.add(bombPrice8).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);
    pricesTable.add(bombPrice9).width(31 * scaleInventoryImg).height(31 * scaleInventoryImg);

    pricesLabelGroup.addActor(pricesTable);
    pricesLabelGroup.setPosition((Constants.SCREENWIDTH - pricesLabelGroup.getWidth()) / 2 + addToPositionX + 3,
            15);
    stage.addActor(pricesLabelGroup);

    if (Constants.ISRUNNINGONSMARTPHONE) {
        Table touchTable = new Table();

        touchTable.add(getContainerWithBombListener(1)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);
        touchTable.add(getContainerWithBombListener(2)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);
        touchTable.add(getContainerWithBombListener(3)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);
        touchTable.add(getContainerWithBombListener(4)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);
        touchTable.add(getContainerWithBombListener(5)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);
        touchTable.add(getContainerWithBombListener(6)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);
        touchTable.add(getContainerWithBombListener(7)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);
        touchTable.add(getContainerWithBombListener(8)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);
        touchTable.add(getContainerWithBombListener(9)).width(31 * scaleInventoryImg)
                .height(31 * scaleInventoryImg);

        touchTable.setPosition((Constants.SCREENWIDTH - touchTable.getWidth()) / 2 + addToPositionX, 35);
        stage.addActor(touchTable);
    }

    generator.dispose();
}