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

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

Introduction

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

Prototype

int right

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

Click Source Link

Usage

From source file:com.agateau.pixelwheels.racescreen.HudContent.java

License:Open Source License

private void createPlayerLabels(AnchorGroup root) {
    Skin skin = mAssets.ui.skin;/*from ww w  .  j  a  v  a 2 s  .  c o m*/
    int playerCount = mGameWorld.getPlayerRacers().size;

    Actor topEdge = root;
    Anchor topAnchor = Anchor.TOP_RIGHT;
    float hMargin = -5;

    boolean singlePlayer = mGameWorld.getPlayerRacers().size == 1;
    for (int idx = 0; idx < playerCount; ++idx) {
        Label rankLabel = new Label("", skin, singlePlayer ? "hudRank" : "smallHudRank");
        rankLabel.setAlignment(Align.right);

        Label lapLabel = new Label("", skin, singlePlayer ? "hud" : "smallHud");
        lapLabel.setAlignment(Align.right);

        root.addPositionRule(rankLabel, Anchor.TOP_RIGHT, topEdge, topAnchor, hMargin, 0);
        root.addPositionRule(lapLabel, Anchor.TOP_RIGHT, rankLabel, Anchor.BOTTOM_RIGHT, 0, 10);

        mRankLabels.add(rankLabel);
        mLapLabels.add(lapLabel);

        topAnchor = Anchor.BOTTOM_RIGHT;
        topEdge = lapLabel;
        hMargin = 0;
    }
}

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;
    }/*  w  w w . ja v  a  2 s  . c om*/
    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.alterego.jelly.screens.PlayGameScreen.java

License:Apache License

private void rebuildStage() {
    buttonPause = new JellyButton(Assets.instance.gameElements.pause);
    buttonPause.setMyScaleSize(1.3f, 1.3f);
    buttonPause.setPosition(8, Const.GAME_HEIGHT - buttonPause.getHeight() - 8);
    buttonPause.addTouchListener(new RunnableAction() {
        public void run() {
            pauseUi.showWindow(true);/*from www . jav a 2  s  .c  o m*/
        }
    }, null);

    buttonReplay = new JellyButton(Assets.instance.gameElements.replay);
    buttonReplay.setMyScaleSize(1.3f, 1.3f);
    buttonReplay.setPosition(8, Const.GAME_HEIGHT - 2 * buttonReplay.getHeight() - 15);
    buttonReplay.addTouchListener(new RunnableAction() {
        public void run() {
            winnerUi.showWindow(true);
            winnerUi.setTime(110);
        }
    }, null);

    Label.LabelStyle labelStyle = new Label.LabelStyle(Assets.instance.fonts.freezers, Color.WHITE);
    gameTime = new Label("0:00", labelStyle);
    gameTime.setAlignment(Align.left);
    gameTime.setPosition(Const.GAME_WIDTH - 135, Const.GAME_HEIGHT - 60);
    gameTime.setWrap(true);
    gameTime.setWidth(350f);

    star = new Image(Assets.instance.gameElements.star);
    star.setScale(0.3f);
    star.setOrigin(star.getWidth() / 2, star.getHeight() / 2);
    star.addAction(Actions.alpha(0f));
    star1 = new Image(Assets.instance.gameElements.star);
    star1.setScale(0.3f);
    star1.setPosition(Const.GAME_WIDTH - 60, Const.GAME_HEIGHT - 92);
    star2 = new Image(Assets.instance.gameElements.star);
    star2.setScale(0.3f);
    star2.setPosition(star1.getX() - 40, Const.GAME_HEIGHT - 92);
    star3 = new Image(Assets.instance.gameElements.star);
    star3.setScale(0.3f);
    star3.setPosition(star2.getX() - 40, Const.GAME_HEIGHT - 92);

    Label.LabelStyle labelStyle2 = new Label.LabelStyle(Assets.instance.fonts.freezers, Color.WHITE);
    freezes = new Label("0", labelStyle2);
    freezes.setText(String.valueOf(LevelData.freezers));
    freezes.setAlignment(Align.right);
    freezes.setPosition(Const.GAME_WIDTH - 200, Const.GAME_HEIGHT - 170);
    freezes.setWrap(true);
    freezes.setWidth(100f);

    freezeFon = new Image(Assets.instance.gameElements.freezeBuyFon);
    freezeFon.setPosition(Const.GAME_WIDTH - 158, Const.GAME_HEIGHT - buttonReplay.getHeight() - 107);
    freezeFon.setScale(0.6f);

    buttonBuyFreeze = new JellyButton(Assets.instance.gameElements.freezeBuy);
    buttonBuyFreeze.setMyScaleSize(1.6f, 1.6f);
    buttonBuyFreeze.setPosition(Const.GAME_WIDTH - buttonBuyFreeze.getWidth() - 15,
            Const.GAME_HEIGHT - buttonReplay.getHeight() - 100);
    buttonBuyFreeze.addTouchListener(new RunnableAction() {
        public void run() {
            marketUi.showWindow(true);
        }
    }, null);

    imgFreeze = new Image(Assets.instance.gameElements.freeze);
    imgFreeze.setOrigin(imgFreeze.getWidth() / 2, imgFreeze.getHeight() / 2);
    imgFreeze.setScale(0.7f);
    imgFreeze.setPosition(freezeFon.getX() - 17, freezeFon.getY() - 25);
    imgFreeze.addAction(Actions.alpha(0f));

    if (addHelp) {
        float delay = 5f;
        if (GamePreferences.instance.isSensorXYZ) {
            delay = 4f;
            helpNavigate = new Image(Assets.instance.menuElements.navigate_tel);
            helpNavigate.setOrigin(helpNavigate.getWidth() / 2, helpNavigate.getHeight() / 2);
            helpNavigate.setScale(0.7f);
            helpNavigate.setPosition(Const.GAME_WIDTH - helpNavigate.getWidth() - 25, Const.GAME_HEIGHT - 500);
            helpNavigate.addAction(sequence(Actions.alpha(0f), Actions.delay(2f), new RunnableAction() {
                public void run() {
                    gameState = GameState.PAUSE;
                }
            }, Actions.alpha(1f, 0.5f), Actions.rotateBy(15f, 0.4f, Interpolation.fade),
                    Actions.rotateBy(-30f, 0.8f, Interpolation.fade),
                    Actions.rotateBy(25f, 0.7f, Interpolation.fade), Actions.alpha(0f, 0.4f)));
        } else {
            helpNavigate = new Image(Assets.instance.menuElements.navigate_finger);
            helpNavigate.setOrigin(helpNavigate.getWidth() / 2, helpNavigate.getHeight() / 2);
            helpNavigate.setScale(0.7f);
            helpNavigate.setPosition(Const.GAME_WIDTH - helpNavigate.getWidth() - 25, Const.GAME_HEIGHT - 500);
            helpNavigate.addAction(sequence(Actions.alpha(0f), Actions.delay(2f), new RunnableAction() {
                public void run() {
                    gameState = GameState.PAUSE;
                }
            }, Actions.alpha(1f, 0.5f), Actions.moveBy(-150f, 0, 0.7f, Interpolation.fade),
                    Actions.moveBy(80f, 0, 0.7f, Interpolation.fade),
                    Actions.moveBy(0, 150f, 0.7f, Interpolation.fade),
                    Actions.moveBy(0, -200f, 0.7f, Interpolation.linear), Actions.alpha(0f, 0.4f)));
        }
        helpFreeze = new Image(Assets.instance.menuElements.navigate_finger);
        helpFreeze.setOrigin(helpFreeze.getWidth() / 2, helpFreeze.getHeight() / 2);
        helpFreeze.setScale(-0.7f, 0.7f);
        helpFreeze.setPosition(helpFreeze.getWidth() + 35, Const.GAME_HEIGHT - 500);
        helpFreeze.addAction(sequence(Actions.alpha(0f), Actions.delay(delay), Actions.alpha(1f, 0.5f),
                Actions.moveBy(LevelData.posX - helpFreeze.getX() + 20,
                        LevelData.posY - helpFreeze.getY() - helpFreeze.getHeight() - 28, 0.7f,
                        Interpolation.fade),
                new RunnableAction() {
                    public void run() {
                        setAnimation(animFreezeOn);
                    }
                }, Actions.alpha(0f, 0.2f)));
    }

    if (addHelp) {
        stage.addActor(helpNavigate);
        stage.addActor(helpFreeze);
    }
    stage.addActor(buttonPause);
    stage.addActor(buttonReplay);
    stage.addActor(gameTime);
    stage.addActor(freezeFon);
    stage.addActor(freezes);
    stage.addActor(buttonBuyFreeze);
    stage.addActor(star1);
    stage.addActor(star2);
    stage.addActor(star3);
    stage.addActor(star);
    stage.addActor(imgFreeze);
    stage.addActor(levelBuilder);
    stage.addActor(winnerUi);
    stage.addActor(marketUi);
    stage.addActor(pauseUi);

}

From source file:com.cometmebro.game.PlanetMenu.java

@Override
public void show() {
    skin.addRegions(atlas2);// w w  w . java2 s.c  om

    blank = "   ";
    one = "o  ";
    two = "oo ";
    three = "ooo";

    currentDangerCount = 1;
    currentDurationCount = 1;
    currentResourcesCount = 1;

    currentDanger = blank;
    currentDuration = blank;
    currentResources = blank;

    sandPlanet = "Sand Planet";
    springPlanet = "Spring Planet";
    simplePlanet = "Grass Planet";
    holidayPlanet = "Winter Wonderland";
    waterPlanet = "Ocean Planet";
    icePlanet = "Ice Planet";
    lavaPlanet = "Lava Planet";
    candyPlanet = "Candy Planet";
    cityPlanet = "Suburban Planet";

    backButtonTex = new Texture(Gdx.files.internal("backbutton.png"));
    Button backButton = new Button(new SpriteDrawable(new Sprite(backButtonTex)));

    backButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addAction(
                    Actions.sequence(Actions.fadeOut(.25f), Actions.delay(.25f), Actions.run(new Runnable() {
                        @Override
                        public void run() {
                            MainMenu menu = new MainMenu(cmb);
                            cmb.setScreen(menu);
                        }
                    })));
        }
    });

    settings = new Texture(Gdx.files.internal("settingsbutton.png"));
    Button settingsButton = new Button(new SpriteDrawable(new Sprite(settings)));

    planetHudTex = new Texture(Gdx.files.internal("planethud.png"));
    SpriteDrawable planethud = new SpriteDrawable(new Sprite(planetHudTex));

    settingsButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            stage.addAction(
                    Actions.sequence(Actions.fadeOut(.25f), Actions.delay(.25f), Actions.run(new Runnable() {
                        @Override
                        public void run() {
                            SettingsMenu menu = new SettingsMenu(cmb);
                            cmb.setScreen(menu);
                        }
                    })));
        }
    });

    buttonUp = new Texture(Gdx.files.internal("roundplaybuttonalt.png"));
    buttonDown = new Texture(Gdx.files.internal("roundplaybuttonaltdown.png"));

    Button.ButtonStyle buttonStyle2 = new Button.ButtonStyle();
    buttonStyle2.up = new SpriteDrawable(new Sprite(buttonUp)).tint(Color.GREEN);
    buttonStyle2.down = new SpriteDrawable(new Sprite(buttonDown)).tint(Color.GREEN);
    play_button = new Button(buttonStyle2);

    play_button.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            PLAY_CLICKED++;
            if (!prefs.getString("type", "").equals("")) {
                stage.addAction(Actions.sequence(Actions.fadeOut(.25f), Actions.delay(.25f),
                        Actions.run(new Runnable() {
                            @Override
                            public void run() {
                                CometMeBro menu = new CometMeBro(cmb, currentDurationCount * 20,
                                        3 / currentDangerCount, currentResourcesCount * 10,
                                        prefs.getString("type", "sand"));
                                cmb.setScreen(menu);
                            }
                        })));
            }
        }
    });

    Button.ButtonStyle style1 = new Button.ButtonStyle();
    style1.up = skin.getDrawable("desert");
    style1.down = skin.getDrawable("desert");
    sand = new Button(style1);

    Button.ButtonStyle style2 = new Button.ButtonStyle();
    style2.up = skin.getDrawable("city");
    style2.down = skin.getDrawable("city");
    city = new Button(style2);

    Button.ButtonStyle style3 = new Button.ButtonStyle();
    style3.up = skin.getDrawable("ice");
    style3.down = skin.getDrawable("ice");
    ice = new Button(style3);

    Button.ButtonStyle style4 = new Button.ButtonStyle();
    style4.up = skin.getDrawable("grassland");
    style4.down = skin.getDrawable("grassland");
    grass = new Button(style4);

    Button.ButtonStyle style5 = new Button.ButtonStyle();
    style5.up = skin.getDrawable("ocean");
    style5.down = skin.getDrawable("ocean");
    ocean = new Button(style5);

    Button.ButtonStyle style6 = new Button.ButtonStyle();
    style6.up = skin.getDrawable("lava");
    style6.down = skin.getDrawable("lava");
    lava = new Button(style6);

    Button.ButtonStyle style7 = new Button.ButtonStyle();
    style7.up = skin.getDrawable("candy");
    style7.down = skin.getDrawable("candy");
    candy = new Button(style7);

    Button.ButtonStyle style8 = new Button.ButtonStyle();
    style8.up = skin.getDrawable("easter");
    style8.down = skin.getDrawable("easter");
    spring = new Button(style8);

    Button.ButtonStyle style9 = new Button.ButtonStyle();
    style9.up = skin.getDrawable("winter");
    style9.down = skin.getDrawable("winter");
    winter = new Button(style9);

    sand.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "sand");
            prefs.putString("title", sandPlanet);
            prefs.flush();
            currentDanger = one;
            currentDuration = two;
            currentResources = one;

            currentDangerCount = 1;
            currentDurationCount = 2;
            currentResourcesCount = 1;

        }
    });

    ice.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "ice");
            prefs.putString("title", icePlanet);
            prefs.flush();
            currentDanger = two;
            currentDuration = two;
            currentResources = two;

            currentDangerCount = 2;
            currentDurationCount = 2;
            currentResourcesCount = 2;
        }
    });

    candy.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "candy");
            prefs.putString("title", candyPlanet);
            prefs.flush();

            currentDanger = one;
            currentDuration = one;
            currentResources = one;

            currentDangerCount = 1;
            currentDurationCount = 1;
            currentResourcesCount = 1;
        }
    });

    spring.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "spring");
            prefs.putString("title", springPlanet);
            prefs.flush();
            currentDanger = one;
            currentDuration = two;
            currentResources = two;

            currentDangerCount = 1;
            currentDurationCount = 2;
            currentResourcesCount = 2;
        }
    });

    winter.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "christmas");
            prefs.putString("title", holidayPlanet);
            prefs.flush();
            currentDanger = two;
            currentDuration = one;
            currentResources = three;

            currentDangerCount = 2;
            currentDurationCount = 1;
            currentResourcesCount = 3;
        }
    });

    lava.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "lava");
            prefs.putString("title", lavaPlanet);
            prefs.flush();
            currentDanger = three;
            currentDuration = two;
            currentResources = three;

            currentDangerCount = 3;
            currentDurationCount = 2;
            currentResourcesCount = 3;
        }
    });

    ocean.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "water");
            prefs.putString("title", waterPlanet);
            prefs.flush();
            currentDanger = two;
            currentDuration = three;
            currentResources = two;

            currentDangerCount = 2;
            currentDurationCount = 3;
            currentResourcesCount = 2;
        }
    });

    grass.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "simple");
            prefs.putString("title", simplePlanet);
            prefs.flush();
            currentDanger = one;
            currentDuration = two;
            currentResources = one;

            currentDangerCount = 1;
            currentDurationCount = 2;
            currentResourcesCount = 1;
        }
    });

    city.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            prefs.putString("type", "city");
            prefs.putString("title", cityPlanet);
            prefs.flush();
            currentDanger = three;
            currentDuration = three;
            currentResources = two;

            currentDangerCount = 3;
            currentDurationCount = 3;
            currentResourcesCount = 2;
        }
    });

    Random rand = new Random();
    int planetRandom = rand.nextInt(8);
    switch (planetRandom) {
    case 0:
        planet1 = sand;
        planet2 = ice;
        planet3 = candy;
        break;
    case 1:
        planet1 = ocean;
        planet2 = ice;
        planet3 = spring;
        break;
    case 2:
        planet1 = lava;
        planet2 = city;
        planet3 = sand;
        break;
    case 3:
        planet1 = grass;
        planet2 = ocean;
        planet3 = spring;
        break;
    case 4:
        planet1 = ice;
        planet2 = lava;
        planet3 = candy;
        break;
    case 5:
        planet1 = sand;
        planet2 = spring;
        planet3 = ocean;
        break;
    case 6:
        planet1 = ice;
        planet2 = grass;
        planet3 = spring;
        break;
    case 7:
        planet1 = candy;
        planet2 = spring;
        planet3 = sand;
        break;

    }

    if (STYLE == 3) {
        table1.setTransform(true);
        table1.add(planet1).width(Value.percentHeight(.25f, table)).height(Value.percentHeight(.25f, table))
                .center().pad(10);
        table1.setX((stage.getWidth() / 4) * 3 - table1.getHeight() / 2);
        table1.setY(stage.getHeight() / 2 - table1.getHeight() / 2);
        table.addActor(table1);

        table2 = new Table();
        table2.setTransform(true);
        table2.add(planet2).width(Value.percentHeight(.15f, table)).height(Value.percentHeight(.15f, table))
                .center().pad(10);
        table2.setX((stage.getWidth() / 4) * 2 - table2.getWidth() / 2);
        table2.setY(stage.getHeight() / 2 - table2.getHeight() / 2);
        table.addActor(table2);

        table3 = new Table();
        table3.setTransform(true);
        table3.add(planet3).width(Value.percentHeight(.2f, table)).height(Value.percentHeight(.2f, table))
                .center().pad(10);
        table3.setX(stage.getWidth() / 4 - table3.getWidth() / 2);
        table3.setY(stage.getHeight() / 2 - table3.getHeight() / 2);
        table.addActor(table3);

    }

    space = new Texture("space16x9fourth.png");
    SpriteDrawable spaceDrawable = new SpriteDrawable(new Sprite(space));

    table.setBackground(spaceDrawable);
    table.setFillParent(true);

    Label resourceslbl = new Label("Resources: ", skin.get("label", Label.LabelStyle.class));
    resourcesDots = new Label(three, skin.get("label", Label.LabelStyle.class));
    Label dangerlbl = new Label("Danger: ", skin.get("label", Label.LabelStyle.class));
    dangerDots = new Label(two, skin.get("label", Label.LabelStyle.class));
    Label durationlbl = new Label("Duration: ", skin.get("label", Label.LabelStyle.class));
    durationDots = new Label(three, skin.get("label", Label.LabelStyle.class));

    pickPlanetLbl = new Label("", skin.get("label", Label.LabelStyle.class));

    crystalCountlbl = new Label(String.valueOf(prefs.getInteger("crystalCount", 0)),
            skin.get("labelblue", Label.LabelStyle.class));

    resourceslbl.setFontScale(.5f);
    dangerlbl.setFontScale(.5f);
    durationlbl.setFontScale(.5f);

    resourcesDots.setFontScale(.5f);
    dangerDots.setFontScale(.5f);
    durationDots.setFontScale(.5f);

    subtable.setBackground(planethud);
    crystaltable.setBackground(skin.getDrawable("bluecrystalhud"));

    subtable.row().colspan(2);
    subtable.add(dangerlbl).left().colspan(1).padBottom(-15).align(Align.right); //.padRight(Value.percentWidth(3.75f))
    subtable.add(dangerDots).left().colspan(1).padBottom(-15).align(Align.left)
            .padRight(subtable.getWidth() / 2);
    subtable.row();
    subtable.add(durationlbl).left().colspan(1).align(Align.right); //.padRight(Value.percentWidth(2.91f));
    subtable.add(durationDots).left().colspan(1).align(Align.left).padRight(subtable.getWidth() / 2);
    subtable.add(play_button).right().width(Value.percentHeight(.1f, table))
            .height(Value.percentHeight(.1f, table));
    subtable.row();
    subtable.add(resourceslbl).left().colspan(1).padTop(-15).align(Align.right); //.padRight(Value.percentWidth(2.6f));
    subtable.add(resourcesDots).left().colspan(1).padTop(-15).align(Align.left)
            .padRight(subtable.getWidth() / 2);

    subtable.setX(0);
    subtable.setY(0);
    subtable.setWidth(CMB.WIDTH);
    subtable.setHeight(CMB.HEIGHT / 4.5f);

    prefs.putString("type", "");
    prefs.putString("title", "");
    prefs.flush();

    planetName = prefs.getString("title", "");
    planet_name = new Label(planetName, skin.get("label", Label.LabelStyle.class));

    table.row();
    table.add(backButton).left().top().width(Value.percentWidth(1f)).height(Value.percentHeight(1f))
            .padBottom(20).padTop(70).padRight(1050);
    table.add(settingsButton).right().top().width(Value.percentWidth(1f)).height(Value.percentHeight(1f))
            .padTop(70);
    table.row();
    table.add(pickPlanetLbl).center().top().padBottom(240);
    table.row();
    table.add(crystaltable).left().bottom().width(Value.percentHeight(.24f, table))
            .height(Value.percentHeight(.187f, table)).padBottom(200).padLeft(-20);
    table.add(planet_name).center().bottom().padLeft(Value.percentWidth(-.9f, table)).padBottom(200);
    table.row();
    table.addActor(subtable);

    crystalCountlbl.setFontScale(.4f);
    crystaltable.row().colspan(1);
    crystaltable.add(crystalCountlbl).colspan(1).bottom().center().align(Align.center).padTop(70).padRight(10);

    stage.addActor(table);

    stage.addAction(Actions.sequence(Actions.fadeIn(1f)));

    Gdx.input.setInputProcessor(stage);
}

From source file:com.cometmebro.game.UpgradeMenu.java

@Override
public void show() {
    Image title = new Image(upgradeskin.getSprite("upgradetitle"));

    ImageButton.ImageButtonStyle button1style = new ImageButton.ImageButtonStyle();
    button1style.up = new SpriteDrawable(upgradeskin.getSprite("upgraderadar"));
    button1style.over = new SpriteDrawable(upgradeskin.getSprite("upgraderadar"));
    button1style.checked = new SpriteDrawable(upgradeskin.getSprite("upgraderadar"));
    button1style.imageChecked = new SpriteDrawable(upgradeskin.getSprite("upgradepurchased"));
    button1style.down = new SpriteDrawable(upgradeskin.getSprite("upgraderadar"));
    final ImageButton button1 = new ImageButton(button1style);

    ImageButton.ImageButtonStyle button2style = new ImageButton.ImageButtonStyle();
    button2style.up = upgradeskin.getDrawable("upgradereload");
    button2style.over = upgradeskin.getDrawable("upgradereload");
    button2style.checked = upgradeskin.getDrawable("upgradereload");
    button2style.imageChecked = upgradeskin.getDrawable("upgradepurchased");
    button2style.down = upgradeskin.getDrawable("upgradereload");
    final ImageButton button2 = new ImageButton(button2style);

    ImageButton.ImageButtonStyle button3style = new ImageButton.ImageButtonStyle();
    button3style.up = new SpriteDrawable(upgradeskin.getSprite("upgradedefense"));
    button3style.over = new SpriteDrawable(upgradeskin.getSprite("upgradedefense"));
    button3style.checked = new SpriteDrawable(upgradeskin.getSprite("upgradedefense"));
    button3style.imageChecked = new SpriteDrawable(upgradeskin.getSprite("upgradepurchased"));
    button3style.down = new SpriteDrawable(upgradeskin.getSprite("upgradedefense"));
    final ImageButton button3 = new ImageButton(button3style);

    ImageButton.ImageButtonStyle button4style = new ImageButton.ImageButtonStyle();
    button4style.up = upgradeskin.newDrawable("upgradeammo");
    button4style.over = upgradeskin.newDrawable("upgradeammo");
    button4style.checked = upgradeskin.newDrawable("upgradeammo");
    button4style.imageChecked = upgradeskin.newDrawable("upgradepurchased");
    button4style.down = upgradeskin.newDrawable("upgradeammo");
    final ImageButton button4 = new ImageButton(button4style);

    String levelstring = "level" + CURRENT_LEVEL;
    String levelstringhover = "level" + CURRENT_LEVEL + "hover";

    ImageButton.ImageButtonStyle button5style = new ImageButton.ImageButtonStyle();
    button5style.up = upgradeskin.newDrawable(levelstring);
    button5style.over = upgradeskin.newDrawable(levelstringhover);
    button5style.checked = upgradeskin.newDrawable(levelstring);
    button5style.down = upgradeskin.newDrawable(levelstring);
    ImageButton levelprogress = new ImageButton(button5style);

    ImageButton.ImageButtonStyle button6style = new ImageButton.ImageButtonStyle();
    button6style.up = upgradeskin.newDrawable("upgradequit");
    button6style.over = upgradeskin.newDrawable("upgradequit");
    button6style.checked = upgradeskin.newDrawable("upgradequit");
    button6style.down = upgradeskin.newDrawable("upgradequit");
    ImageButton quit = new ImageButton(button6style);

    ImageButton.ImageButtonStyle button7style = new ImageButton.ImageButtonStyle();
    button7style.up = upgradeskin.newDrawable("upgradenextwave");
    button7style.over = upgradeskin.newDrawable("upgradenextwave");
    button7style.down = upgradeskin.newDrawable("upgradenextwave");
    ImageButton nextlevel = new ImageButton(button7style);

    //table.add(button1).right().top().padRight(Value.percentWidth(-.2f, table)).;
    //table.add(button2).right().bottom().padRight(Value.percentWidth(-.2f, table));

    short bits = UPGRADE_BITS;
    if (bits - AMMO_BIT >= 0) {
        bits -= AMMO_BIT;//  w ww  .j a v a 2s  .c o m
        button4.setChecked(true);
        button4.setDisabled(true);
    }
    if (bits - DEFENSE_BIT >= 0) {
        bits -= DEFENSE_BIT;
        button3.setChecked(true);
        button3.setDisabled(true);
    }
    if (bits - RELOAD_BIT >= 0) {
        bits -= RELOAD_BIT;
        button2.setChecked(true);
        button2.setDisabled(true);
    }
    if (bits - RADAR_BIT >= 0) {
        button1.setChecked(true);
        button1.setDisabled(true);
    }

    button1.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            if (prefs.getInteger("crystalCount", 0) >= 500) {
                button1.setDisabled(true);

                UPGRADE_BITS += RADAR_BIT;
                int newCrystalCount = prefs.getInteger("crystalCount", 0) - 500;
                if (newCrystalCount < 500) {
                    button1.setDisabled(true);
                    button2.setDisabled(true);
                    button3.setDisabled(true);
                    button4.setDisabled(true);
                }
                prefs.putInteger("crystalCount", newCrystalCount);
                prefs.flush();
                totalCrystalsCollected.setText(String.valueOf(prefs.getInteger("crystalCount", 0)));
            }
        }
    });

    button2.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            if (prefs.getInteger("crystalCount", 0) >= 500) {
                button2.setDisabled(true);

                UPGRADE_BITS += RELOAD_BIT;
                int newCrystalCount = prefs.getInteger("crystalCount", 0) - 500;
                if (newCrystalCount < 500) {
                    button1.setDisabled(true);
                    button2.setDisabled(true);
                    button3.setDisabled(true);
                    button4.setDisabled(true);
                }
                prefs.putInteger("crystalCount", newCrystalCount);
                prefs.flush();
                totalCrystalsCollected.setText(String.valueOf(prefs.getInteger("crystalCount", 0)));
            }
        }
    });

    button3.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            if (prefs.getInteger("crystalCount", 0) >= 500) {
                button3.setDisabled(true);

                UPGRADE_BITS += DEFENSE_BIT;
                int newCrystalCount = prefs.getInteger("crystalCount", 0) - 500;
                if (newCrystalCount < 500) {
                    button1.setDisabled(true);
                    button2.setDisabled(true);
                    button3.setDisabled(true);
                    button4.setDisabled(true);
                }
                prefs.putInteger("crystalCount", newCrystalCount);
                prefs.flush();
                totalCrystalsCollected.setText(String.valueOf(prefs.getInteger("crystalCount", 0)));
            }
        }
    });

    button4.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            if (prefs.getInteger("crystalCount", 0) >= 500) {
                button4.setDisabled(true);

                UPGRADE_BITS += AMMO_BIT;
                int newCrystalCount = prefs.getInteger("crystalCount", 0) - 500;
                if (newCrystalCount < 500) {
                    button1.setDisabled(true);
                    button2.setDisabled(true);
                    button3.setDisabled(true);
                    button4.setDisabled(true);
                }
                prefs.putInteger("crystalCount", newCrystalCount);
                prefs.flush();
                totalCrystalsCollected.setText(String.valueOf(prefs.getInteger("crystalCount", 0)));
            }
        }
    });

    quit.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            prefs.putInteger("cometsDestroyed", 0);
            prefs.putInteger("buildingsDestroyed", 0);
            prefs.putInteger("crystalsCollected", 0);
            prefs.flush();
            stage.addAction(
                    Actions.sequence(Actions.fadeOut(.25f), Actions.delay(.25f), Actions.run(new Runnable() {
                        @Override
                        public void run() {
                            MainMenu CMB = new MainMenu(cmb);
                            cmb.setScreen(CMB);
                        }
                    })));
        }
    });

    nextlevel.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeListener.ChangeEvent event, Actor actor) {
            prefs.putInteger("cometsDestroyed", 0);
            prefs.putInteger("buildingsDestroyed", 0);
            prefs.putInteger("crystalsCollected", 0);
            prefs.flush();
            stage.addAction(
                    Actions.sequence(Actions.fadeOut(.25f), Actions.delay(.25f), Actions.run(new Runnable() {
                        @Override
                        public void run() {
                            if (CURRENT_LEVEL != 6) {
                                CometMeBro CMB = new CometMeBro(cmb, LEVEL_LENGTH, 2f / CURRENT_LEVEL, structs,
                                        CURRENT_LEVEL, UPGRADE_BITS, TYPE);
                                cmb.setScreen(CMB);
                            } else {
                                MainMenu CMB = new MainMenu(cmb);
                                cmb.setScreen(CMB);
                            }
                        }
                    })));
        }
    });

    table_upgrades.add(title).width(600).height(200).padTop(5).padBottom(5).top().colspan(2).expand();
    table_upgrades.row();

    table_upgrades.add(button1).height(250).width(250).padLeft(20).padBottom(20);
    table_upgrades.add(button2).height(250).width(250).padRight(20).padBottom(20);
    table_upgrades.row();
    table_upgrades.add(button3).height(250).width(250).padLeft(20);
    table_upgrades.add(button4).height(250).width(250).padRight(20);

    table.add(table_upgrades).colspan(2).padBottom(10);

    //        table.add(pane).left().colspan(2);
    //        table.add(levelprogress).left().height(Value.percentHeight(1f)).width(Value.percentWidth(1f)).padLeft(Value.percentWidth(.10f)).padRight(Value.percentWidth(.20f));

    Label resultsLbl = new Label("Results", upgradeskin.get("label", Label.LabelStyle.class));

    Label cometsDestroyedLbl = new Label("Comets Destroyed:", upgradeskin.get("label", Label.LabelStyle.class));
    Label buildingsDestroyedLbl = new Label("Buildings Destroyed:",
            upgradeskin.get("label", Label.LabelStyle.class));
    Label crystalsCollectedLbl = new Label("Crystals Collected:",
            upgradeskin.get("label", Label.LabelStyle.class));
    Label totalCrystalsCollectedLbl = new Label("Total Crystals:",
            upgradeskin.get("label", Label.LabelStyle.class));

    Label cometsDestroyed = new Label(String.valueOf(prefs.getInteger("cometsDestroyed", 0)),
            upgradeskin.get("label", Label.LabelStyle.class));
    Label buildingsDestroyed = new Label(String.valueOf(prefs.getInteger("buildingsDestroyed", 0)),
            upgradeskin.get("label", Label.LabelStyle.class));
    Label crystalsCollected = new Label(String.valueOf(prefs.getInteger("crystalsCollected", 0)),
            upgradeskin.get("label", Label.LabelStyle.class));
    totalCrystalsCollected = new Label(String.valueOf(prefs.getInteger("crystalCount", 0)),
            upgradeskin.get("label", Label.LabelStyle.class));

    prefs.putInteger("cometsDestroyed", 0);
    prefs.putInteger("buildingsDestroyed", 0);
    prefs.putInteger("crystalsCollected", 0);
    prefs.flush();

    cometsDestroyedLbl.setFontScale(.4f);
    buildingsDestroyedLbl.setFontScale(.4f);
    crystalsCollectedLbl.setFontScale(.4f);
    totalCrystalsCollectedLbl.setFontScale(.5f);

    cometsDestroyed.setFontScale(.4f);
    buildingsDestroyed.setFontScale(.4f);
    crystalsCollected.setFontScale(.4f);
    totalCrystalsCollected.setFontScale(.5f);

    table_status.add(resultsLbl).center().top().colspan(2).padBottom(50);
    table_status.row();
    table_status.add(cometsDestroyedLbl).right().align(Align.right);
    table_status.add(cometsDestroyed).center().align(Align.center);
    table_status.row();
    table_status.add(buildingsDestroyedLbl).right().align(Align.right);
    table_status.add(buildingsDestroyed).center().align(Align.center);
    table_status.row();
    table_status.add(crystalsCollectedLbl).right().align(Align.right);
    table_status.add(crystalsCollected).center().align(Align.center);
    table_status.row();
    table_status.add(totalCrystalsCollectedLbl).right().align(Align.right).padBottom(170).padTop(30);
    table_status.add(totalCrystalsCollected).center().align(Align.center).padBottom(170).padTop(30);
    table_status.row();
    table_status.add(quit).bottom().height(Value.percentWidth(.075f, table))
            .width(Value.percentWidth(.18f, table)).padLeft(Value.percentWidth(.05f))
            .padRight(Value.percentWidth(.05f)).padBottom(Value.percentHeight(.05f));
    table_status.add(nextlevel).bottom().height(Value.percentWidth(.075f, table))
            .width(Value.percentWidth(.24f, table)).padRight(Value.percentWidth(.05f))
            .padBottom(Value.percentHeight(.05f));

    table.add(table_status).bottom().colspan(2).padBottom(10);

    space = new Texture("space16x9thirddark.png");
    SpriteDrawable spaceDrawable = new SpriteDrawable(new Sprite(space));

    table.setBackground(spaceDrawable);
    table.setFillParent(true);

    stage.addActor(table);

    Gdx.input.setInputProcessor(stage);

    System.out.println("UPGRADE_BITS: " + UPGRADE_BITS);
}

From source file:com.gamestudio24.martianrun.actors.Score.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    super.draw(batch, parentAlpha);
    if (getScore() == 0) {
        return;//w ww  .j  av a2 s . c o  m
    }
    font.draw(batch, String.format("%d", getScore()), bounds.x, bounds.y, bounds.width, Align.right, true);
}

From source file:com.jmolina.orb.widgets.ui.Card.java

License:Open Source License

public Card(AssetManager am, GameManager gm, String title, String time, ScreenManager.Key level) {
    super(am);/*from w  w  w.j a  v  a  2 s.c  o  m*/

    gameManager = gm;

    fullFrame = new Image(getAsset(Asset.UI_CARD_FRAME, Texture.class));
    coverFrame = new Image(getAsset(Asset.UI_CARD_COVER_FRAME, Texture.class));
    cover = new Image(getCoverTexture(level));
    coverBlur = new Image(getCoverBlurTexture(level));
    background = new Image(getAsset(Asset.UI_CARD_BACKGROUND, Texture.class));
    padlock = new Image(getAsset(Asset.UI_CARD_PADLOCK, Texture.class));

    fullFrame.setPosition(0, 0);
    fullFrame.addAction(alpha(0));
    fullFrame.act(0);
    coverFrame.setPosition(0, 0);
    background.setPosition(0f, 0f);
    cover.setPosition(0f, 0f);
    coverBlur.setPosition(0f, 0f);
    padlock.setPosition(Utils.cell(1.75f), Utils.cell(1));

    Label.LabelStyle titleStyle = new Label.LabelStyle();
    titleStyle.fontColor = new Color(Var.COLOR_GREEN_DARK);
    titleStyle.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_BOLD_45),
            findRegion(Atlas.FONT_ROBOTO_BOLD_45));

    titleLabel = new Label(title, titleStyle);
    titleLabel.setTouchable(Touchable.disabled);
    titleLabel.setPosition(Utils.cell(5), Utils.cell(2.75f));
    titleLabel.setHeight(Utils.cell(1));
    titleLabel.setWidth(Utils.cell(4.5f));
    titleLabel.setAlignment(Align.right);

    Label.LabelStyle timeStyle = new Label.LabelStyle();
    timeStyle.fontColor = new Color(Var.COLOR_LILAC_DARK);
    timeStyle.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_REGULAR_30),
            findRegion(Atlas.FONT_ROBOTO_REGULAR_30));

    timeLabel = new Label(time, timeStyle);
    timeLabel.setTouchable(Touchable.disabled);
    timeLabel.setPosition(Utils.cell(5), Utils.cell(0.25f));
    timeLabel.setHeight(Utils.cell(0.75f));
    timeLabel.setWidth(Utils.cell(4.5f));
    timeLabel.setAlignment(Align.right);

    addActor(background);
    addActor(coverBlur);
    addActor(cover);
    addActor(coverFrame);
    addActor(fullFrame);
    addActor(padlock);
    addActor(titleLabel);
    addActor(timeLabel);

    setFrame(fullFrame);

    setHeight(Utils.cell(4));
    lock();
}

From source file:com.jmolina.orb.widgets.ui.LadderRow.java

License:Open Source License

/**
 * Constructor//from   w ww.j  av a 2  s.  c om
 *
 * @param am AssetManager
 * @param rank Rango
 * @param time Tiempo
 * @param numericRating Rating numerico (medallas)
 */
public LadderRow(AssetManager am, int rank, float time, int numericRating) {
    super(am);

    Label.LabelStyle regular = new Label.LabelStyle();
    Label.LabelStyle strong = new Label.LabelStyle();
    regular.fontColor = new Color(Var.COLOR_LILAC_DARK);
    strong.fontColor = new Color(Var.COLOR_LILAC_DARK);
    regular.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_REGULAR_30),
            findRegion(Atlas.FONT_ROBOTO_REGULAR_30));
    strong.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_BOLD_30),
            findRegion(Atlas.FONT_ROBOTO_BOLD_30));

    rankLabel = new Label(String.valueOf(rank), strong);
    rankLabel.setPosition(Utils.cell(0), Utils.cell(0));
    rankLabel.setSize(Utils.cell(1), Utils.cell(0.5f));
    rankLabel.setAlignment(Align.left);

    timeLabel = new Label(formatTime(time), regular);
    timeLabel.setPosition(Utils.cell(1), Utils.cell(0));
    timeLabel.setSize(Utils.cell(2), Utils.cell(0.5f));
    timeLabel.setAlignment(Align.right);

    userLabel = new Label("You", strong);
    userLabel.setPosition(Utils.cell(4), Utils.cell(0));
    userLabel.setSize(Utils.cell(3.5f), Utils.cell(0.5f));
    userLabel.setAlignment(Align.left);
    userLabel.setEllipsis(true);

    rating = new Rating(getAssetManager(), numericRating);
    rating.setPositionGrid(5, 0);
    rating.setScale(0.5f);
    rating.setHeadingVisibility(false);

    addActor(rankLabel);
    addActor(timeLabel);

    if (time > 0) {
        addActor(userLabel);
        addActor(rating);
    }

    setHeight(Utils.cell(0.5f));
}

From source file:com.jmolina.orb.widgets.ui.Notice.java

License:Open Source License

/**
 * Constructor/*from ww  w  .  j  a  v  a  2s  .c o  m*/
 *
 * @param am AssetManager
 */
public Notice(AssetManager am) {
    super(am);

    Label.LabelStyle labelStyle = new Label.LabelStyle();
    labelStyle.fontColor = new Color(Var.COLOR_LILAC_DARK);
    labelStyle.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_REGULAR_30),
            findRegion(Atlas.FONT_ROBOTO_REGULAR_30));

    this.author = new Label(Var.APP_AUTHOR, labelStyle);
    this.author.setTouchable(Touchable.disabled);
    this.author.setPosition(Utils.cell(0), Utils.cell(0));
    this.author.setHeight(Utils.cell(0.5f));
    this.author.setWidth(Utils.cell(10f));
    this.author.setAlignment(Align.left);

    this.version = new Label("v" + Var.APP_VERSION, labelStyle);
    this.version.setTouchable(Touchable.disabled);
    this.version.setPosition(Utils.cell(0), Utils.cell(0));
    this.version.setHeight(Utils.cell(0.5f));
    this.version.setWidth(Utils.cell(10f));
    this.version.setAlignment(Align.right);

    addActor(this.author);
    addActor(this.version);
}

From source file:com.jmolina.orb.widgets.ui.Stat.java

License:Open Source License

/**
 * Constructor//from   ww  w . ja  va2 s  .co  m
 *
 * @param am AssetManager
 * @param name Nombre
 * @param value Valor del dato
 * @param unit Unidad del dato
 */
public Stat(AssetManager am, String name, float value, String unit) {
    super(am);

    nameStyle = new Label.LabelStyle();
    dataStyle = new Label.LabelStyle();

    nameStyle.fontColor = new Color(Var.COLOR_LILAC_DARK);
    dataStyle.fontColor = new Color(Var.COLOR_BLACK);
    nameStyle.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_REGULAR_45),
            findRegion(Atlas.FONT_ROBOTO_REGULAR_45));
    dataStyle.font = new BitmapFont(Gdx.files.internal(Font.FONT_ROBOTO_REGULAR_45),
            findRegion(Atlas.FONT_ROBOTO_REGULAR_45));

    this.name = new Label(name, nameStyle);
    this.name.setTouchable(Touchable.disabled);
    this.name.setPosition(0f, 0f);
    this.name.setHeight(Utils.cell(1));
    this.name.setWidth(Utils.cell(6));
    this.name.setAlignment(Align.left);

    this.data = new Label(formatStat(value, unit), dataStyle);
    this.data.setTouchable(Touchable.disabled);
    this.data.setPosition(Utils.cell(6), 0f);
    this.data.setHeight(Utils.cell(1));
    this.data.setWidth(Utils.cell(4));
    this.data.setAlignment(Align.right);

    addActor(this.name);
    addActor(this.data);
    setTransform(false);
    setHeight(Utils.cell(1));
}