Example usage for com.badlogic.gdx.utils Align topRight

List of usage examples for com.badlogic.gdx.utils Align topRight

Introduction

In this page you can find the example usage for com.badlogic.gdx.utils Align topRight.

Prototype

int topRight

To view the source code for com.badlogic.gdx.utils Align topRight.

Click Source Link

Usage

From source file:com.agateau.ui.UiBuilder.java

License:Apache License

private static int parseAlign(XmlReader.Element element) {
    String alignText = element.getAttribute("align", "");
    if (alignText.isEmpty()) {
        return -1;
    }/*from w  w w .j a v  a2  s . com*/
    if (alignText.equals("center")) {
        return Align.center;
    } else if (alignText.equals("centerLeft")) {
        return Align.left;
    } else if (alignText.equals("centerRight")) {
        return Align.right;
    } else if (alignText.equals("topLeft")) {
        return Align.topLeft;
    } else if (alignText.equals("topCenter")) {
        return Align.top;
    } else if (alignText.equals("topRight")) {
        return Align.topRight;
    } else if (alignText.equals("bottomLeft")) {
        return Align.bottomLeft;
    } else if (alignText.equals("bottomCenter")) {
        return Align.bottom;
    } else if (alignText.equals("bottomRight")) {
        return Align.bottomRight;
    } else {
        throw new RuntimeException("Unknown value of 'align': " + alignText);
    }
}

From source file:com.bladecoder.engine.ui.LoadSaveScreen.java

License:Apache License

@Override
public void show() {
    float size = DPIUtils.getPrefButtonSize();
    float pad = DPIUtils.getMarginSize();
    final Skin skin = ui.getSkin();
    final World world = World.getInstance();

    // loadScreenMode = ui.getScreen(Screens.LOAD_GAME_SCREEN) == this;
    loadScreenMode = world.getCurrentScene() == null;

    stage = new Stage(new ScreenViewport());

    slotWidth = (int) (stage.getViewport().getWorldWidth() / (ROW_SLOTS + 1) - 2 * pad);
    slotHeight = (int) (slotWidth * stage.getViewport().getScreenHeight()
            / stage.getViewport().getScreenWidth());

    LoadSaveScreenStyle style = skin.get(LoadSaveScreenStyle.class);

    Drawable bg = style.background;//w w w  . ja  v a  2 s  . co  m

    if (bg == null && style.bgFile != null) {
        bgTexFile = new Texture(EngineAssetManager.getInstance().getResAsset(style.bgFile));
        bgTexFile.setFilter(TextureFilter.Linear, TextureFilter.Linear);

        bg = new TextureRegionDrawable(new TextureRegion(bgTexFile));
    }

    Table table = new Table(skin);
    table.setFillParent(true);
    table.center();
    table.pad(pad);

    Label title = new Label(loadScreenMode ? I18N.getString("ui.load") : I18N.getString("ui.save"), skin,
            "title");

    Button back = new Button(skin, "back");

    back.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {
            ui.setCurrentScreen(Screens.MENU_SCREEN);
        }
    });

    Table header = new Table();
    // header.padBottom(pad);
    Container<Button> cont = new Container<Button>(back);
    cont.size(size);
    header.add(cont);
    header.add(title).fillX().expandX().left();
    table.add(header).fillX().expandX().left();

    if (bg != null)
        table.setBackground(bg);

    table.addListener(new InputListener() {
        @Override
        public boolean keyUp(InputEvent event, int keycode) {
            if (keycode == Input.Keys.ESCAPE || keycode == Input.Keys.BACK)
                if (world.getCurrentScene() != null)
                    ui.setCurrentScreen(Screens.SCENE_SCREEN);

            return true;
        }
    });

    final PagedScrollPane scroll = new PagedScrollPane();
    scroll.setFlingTime(0.1f);
    scroll.setPageSpacing(25);

    Table slots = new Table().pad(pad);
    slots.defaults().pad(pad).size(slotWidth + pad, slotHeight + pad * 2).top();
    int c = 0;

    // Add "new slot" slot for save screen
    if (!loadScreenMode) {
        slots.add(getSlotButton(Long.toString(new Date().getTime()))).fill().expand();
        c++;
    }

    final List<String> sl = getSlots();

    Collections.sort(sl);

    for (int j = sl.size() - 1; j >= 0; j--) {

        String s = sl.get(j);

        if (c % ROW_SLOTS == 0 && c % (ROW_SLOTS * COL_SLOTS) != 0)
            slots.row();

        if (c != 0 && c % (ROW_SLOTS * COL_SLOTS) == 0) {
            scroll.addPage(slots);
            slots = new Table().pad(pad);
            slots.defaults().pad(pad).size(slotWidth + pad, slotHeight + pad * 2).top();
        }

        Button removeButton = new Button(skin, "delete_game");
        removeButton.setName(s);
        removeButton.addListener(removeClickListener);

        Container<Button> container = new Container<Button>(removeButton);
        container.size(DPIUtils.getPrefButtonSize() * .75f);
        container.align(Align.topRight);

        slots.stack(getSlotButton(s), container).fill().expand();

        c++;
    }

    // Add last page
    if (slots.getCells().size > 0)
        scroll.addPage(slots);

    table.row();

    if (loadScreenMode && sl.size() == 0) {
        Label lbl = new Label(I18N.getString("ui.noSavedGames"), skin, "title");
        lbl.setAlignment(Align.center);
        table.add(lbl).expand().fill();
    } else {
        table.add(scroll).expand().fill();
    }

    table.pack();

    stage.setKeyboardFocus(table);
    stage.addActor(table);

    pointer = new Pointer(ui.getSkin());
    stage.addActor(pointer);

    Gdx.input.setInputProcessor(stage);
}

From source file:com.nhydock.storymode.scenes.title.TitleSequence.java

@Override
public void init() {
    final TitleSequence ui = this;

    // create title sequence
    final Skin skin = manager.get(DataDirs.Home + "title.json", Skin.class);
    final Skin uiskin = shared.getResource(DataDirs.Home + "uiskin.json", Skin.class);

    //clouds/*from  ww  w . ja  v a  2  s .  c  om*/
    {

        Image goddess = new Image(uiskin, "goddess");
        goddess.setSize(32, 32);
        goddess.setPosition(getWidth(), getHeight() - 96f);
        goddess.setOrigin(Align.center);
        addActor(goddess);

        Image cloudsPan1 = new Image(new TiledDrawable(uiskin.getRegion("clouds")));
        Image cloudsPan2 = new Image(new TiledDrawable(uiskin.getRegion("clouds")));
        cloudsPan1.setWidth(getWidth() * 5);
        cloudsPan2.setWidth(getWidth() * 5);

        cloudsPan1.setPosition(0, 0, Align.topLeft);
        cloudsPan2.setPosition(0, 0, Align.topLeft);
        addActor(cloudsPan1);
        addActor(cloudsPan2);

        cloudsPan1.addAction(Actions.sequence(Actions.moveToAligned(getWidth(), 0, Align.topRight),
                Actions.delay(10f), Actions.parallel(Actions.moveBy(0, 140f, 3f, Interpolation.sineOut),
                        Actions.moveBy(getWidth() * 5, 0, 50f))));

        cloudsPan2.addAction(Actions.sequence(Actions.moveToAligned(getWidth(), 0, Align.topRight),
                Actions.delay(10f), Actions.parallel(Actions.moveBy(0, 80f, 3f, Interpolation.sineOut),
                        Actions.moveBy(getWidth() * 5, 0, 40f))));

        goddess.addAction(Actions.sequence(Actions.delay(20f),
                Actions.parallel(Actions.repeat(5, Actions.rotateBy(360, .4f)),
                        Actions.moveBy(-getWidth() - 32, 0f, 2f)),
                Actions.delay(1f),
                Actions.addAction(Actions.moveBy(0, getHeight(), 1f, Interpolation.sineIn), cloudsPan1),
                Actions.addAction(Actions.moveBy(0, getHeight(), 1f, Interpolation.sineIn), cloudsPan2)));
    }

    // initial text
    {
        Table textGrid = new Table();
        textGrid.setFillParent(true);
        textGrid.pad(40f);

        Label text = new Label(
                "This game is Shareware!\n\nThat means it's completely free to download and distribute.\n\nIf you'd like to be nice, you can donate and learn more at http://nhydock.github.io/Storymode",
                skin);
        text.setWrap(true);
        text.setAlignment(Align.center);
        text.addAction(Actions.sequence(Actions.alpha(0f), Actions.alpha(1f, 1f)));
        textGrid.add(text).expandX().fillX();
        text = new Label("~Thanks a bunch!", skin);
        text.setWrap(true);
        text.setAlignment(Align.right);
        text.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(3f), Actions.alpha(1f, 1f)));
        textGrid.row();
        textGrid.add(text).expandX().fillX().padRight(60f);
        textGrid.addAction(Actions.sequence(Actions.alpha(1f), Actions.delay(8f), Actions.alpha(0f, 2f),
                Actions.run(new PlayBGM(manager.get(DataDirs.Audio + "title.mp3", Music.class)))));
        addActor(textGrid);
    }

    // credits animation
    {
        Table textGrid = new Table();
        textGrid.setFillParent(true);
        textGrid.pad(40f);

        Label text = new Label("Graphics, Programming, Project Lead", skin);
        text.setAlignment(Align.center);
        textGrid.add(text).expandX().fillX();
        textGrid.row();
        text = new Label("Nicholas Hydock", skin);
        text.setAlignment(Align.center);
        textGrid.add(text).expandX().fillX();
        textGrid.row();
        text = new Label(" ", skin);
        text.setAlignment(Align.center);
        textGrid.add(text).expandX().fillX();
        textGrid.row();
        text = new Label("Ideas, Suggestions, Emotional Support, & Bros4Lyfe", skin);
        text.setAlignment(Align.center);
        textGrid.add(text).expandX().fillX();
        textGrid.row();
        text = new Label("Patrick Flanagan", skin);
        text.setAlignment(Align.center);
        textGrid.add(text).expandX().fillX();
        textGrid.row();
        text = new Label("Matthew Hydock", skin);
        text.setAlignment(Align.center);
        textGrid.add(text).expandX().fillX();
        textGrid.row();
        text = new Label("Andrew Hoffman", skin);
        text.setAlignment(Align.center);
        textGrid.add(text).expandX().fillX();

        textGrid.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(10f), Actions.alpha(1f, .75f),
                Actions.delay(4f), Actions.alpha(0f, .75f)));
        addActor(textGrid);
    }

    // display tool logos
    {
        Group group = new Group();
        Image tools = new Image(skin.getDrawable("tools"));
        tools.setPosition(getWidth() / 2 - tools.getWidth() / 2, getHeight() / 2 - tools.getHeight() / 2);
        Label label = new Label(
                "All music is licensed under Creative-Commons BY(-NC) or other permissive licenses.\nAll attribution can be found in the README",
                skin, "small");
        label.setPosition(getWidth() / 2f, getHeight() / 2f - 80f, Align.top);
        label.setAlignment(Align.center);
        group.addActor(tools);
        group.addActor(label);
        group.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(16f), Actions.alpha(1f, .75f),
                Actions.delay(4f), Actions.alpha(0f, .75f)));
        addActor(group);
    }

    // cool animation
    {
        Group cool = new Group();
        cool.setSize(getWidth(), getHeight());
        Group group = new Group();
        Image cliff = new Image(skin.getRegion("cliff"));
        group.addAction(Actions.sequence(Actions.moveTo(0, -cliff.getHeight()), Actions.delay(24f),
                Actions.moveTo(0, 0, 4f)));
        group.addActor(cliff);
        final Image character = new Image(skin.getRegion("back"));
        character.setSize(96f, 96f);
        group.addActor(character);
        character.addAction(
                Actions.sequence(Actions.moveTo(200f, 200f), Actions.delay(31f), Actions.run(new Runnable() {

                    @Override
                    public void run() {
                        character.setDrawable(skin.getDrawable("character"));
                    }

                }), Actions.moveTo(-character.getWidth() / 2, -character.getHeight(), 1f), Actions.delay(10f),
                        Actions.run(new Runnable() {

                            @Override
                            public void run() {
                                character.setDrawable(skin.getDrawable("back"));
                            }

                        }), Actions.moveTo(200f, 200f, 1f), Actions.delay(.2f), Actions.run(new Runnable() {

                            @Override
                            public void run() {
                                character.setDrawable(skin.getDrawable("character"));
                            }

                        })));

        Image castle = new Image(skin.getRegion("castle"));
        castle.addAction(
                Actions.sequence(Actions.moveToAligned(getWidth() - castle.getWidth(), 0f, Align.topLeft),
                        Actions.delay(24f), Actions.moveBy(0, getHeight(), 4f)));
        Image lightning = new Image(skin.getRegion("lightning"));
        lightning.setPosition(getWidth() - castle.getWidth(), getHeight() - castle.getHeight());
        lightning.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(29f), Actions.alpha(1f, .1f),
                Actions.delay(.3f), Actions.alpha(.3f, .3f), Actions.alpha(1f, .1f), Actions.delay(.3f),
                Actions.alpha(0f, 1f)));

        Image logo = new Image(skin.getRegion("logo"));
        logo.addAction(Actions.sequence(Actions.alpha(0f),
                Actions.moveTo(0, getHeight() - logo.getHeight() + 5f), Actions.delay(34f),
                Actions.alpha(1f, 1f),
                Actions.forever(Actions.sequence(Actions.moveTo(0, getHeight() - logo.getHeight() + 5f, 2f),
                        Actions.moveTo(0, getHeight() - logo.getHeight() - 5f, 2f)))));

        Table table = new Table();

        Label label = new Label("Title theme", skin, "small");
        label.setAlignment(Align.right);
        table.add(label).expandX().fillX();
        table.row();
        label = new Label("Anamanaguchi - Helix Nebula", skin, "small");
        label.setAlignment(Align.right);
        table.add(label).expandX().fillX();
        table.row();
        table.pad(10f);
        table.pack();
        table.addAction(Actions.sequence(Actions.alpha(0f), Actions.moveTo(getWidth() - table.getWidth(), 0),
                Actions.delay(40f), Actions.alpha(1f, 1f)));

        cool.addActor(castle);
        cool.addActor(lightning);
        cool.addActor(group);
        cool.addActor(logo);
        cool.addActor(table);

        cool.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(24f), Actions.alpha(1f),
                Actions.delay(40f), Actions.alpha(0f, 1f), Actions.delay(1f), Actions.run(new Runnable() {

                    @Override
                    public void run() {
                        SceneManager.switchToScene("title");
                    }

                }), Actions.delay(1.5f), Actions.run(new Runnable() {

                    @Override
                    public void run() {
                    }

                })));
        addActor(cool);

        final Label startLabel = new Label("Press Start", skin);
        startLabel.setPosition(getWidth() - 360f, 120f);
        startLabel.addAction(Actions.sequence(Actions.alpha(0f), Actions.delay(38f), Actions.alpha(1f, .3f),
                Actions.run(new Runnable() {

                    @Override
                    public void run() {
                        ui.addListener(new InputListener() {
                            @Override
                            public boolean touchDown(InputEvent evt, float x, float y, int pointer,
                                    int button) {
                                if (button == Buttons.LEFT) {
                                    SceneManager.switchToScene("newgame");
                                    return true;
                                }
                                return false;
                            }
                        });
                    }

                }), Actions.delay(24f), Actions.alpha(0f, 1f)));
        addActor(startLabel);

    }

    // make sure all initial steps are set
    act();

    addListener(new InputListener() {
        @Override
        public boolean keyDown(InputEvent evt, int keycode) {
            // skip the intro
            if (Input.ACCEPT.match(keycode) || Input.CANCEL.match(keycode)) {
                SceneManager.switchToScene("newgame");
                return true;
            }
            return false;
        }

        @Override
        public boolean touchDown(InputEvent evt, float x, float y, int pointer, int button) {
            if (button == Buttons.RIGHT) {
                SceneManager.switchToScene("newgame");
                return true;
            }
            return false;
        }
    });
}

From source file:com.trgk.touchwave.menuscene.MenuScene.java

License:Open Source License

public MenuScene() {
    super(new Stage(new ScreenViewport()));

    uiGroup = new ScreenFillingGroup(150, 100);
    this.getStage().addActor(uiGroup);

    // Window/*from   w w  w.  j  a v a2  s . c o  m*/
    uiGroup.addActor(buildWindow());

    // Pause
    pauseButton = new Image(TGResources.getInstance().getAtlasSprite("infobutton"));
    pauseButton.setScale(10 / 128f);
    pauseButton.setOrigin(Align.topRight);
    final MenuScene this2 = this;
    pauseButton.addListener(new ClickListener() {
        @Override
        public void clicked(InputEvent event, float x, float y) {
            getSceneManager().setCurrentScene(new AboutScene(this2));
            super.clicked(event, x, y);
        }
    });
    uiGroup.addActor(pauseButton);

    // Version
    versionString = new TGText(versionStr, 3, 0, 0, Color.BLACK);
    uiGroup.addActor(versionString);
    versionString.setOrigin(Align.topLeft);
}

From source file:com.trgk.touchwave.menuscene.MenuScene.java

License:Open Source License

@Override
public void draw() {
    Vector2 topRight = uiGroup.getlogicalScreenTopRight();
    pauseButton.setPosition(topRight.x - 2, topRight.y - 2, Align.topRight);

    Vector2 topLeft = uiGroup.getlogicalScreenTopLeft();
    versionString.setPosition(topLeft.x + 2, topLeft.y - 2, Align.topLeft);

    super.draw();
}