List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Label Label
public Label(CharSequence text, Skin skin, String fontName, String colorName)
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.AboutScreen.java
License:Open Source License
@Override public void show() { super.show(); //Set Background addBackGroundShift("GdxMenus/settings/settingsbg.jpg"); // Note: no accent with the default font and multiple spaces or \t are not working String cAboutText = "App's name:\n" + " Bouboule\n\n" + "Authors: (v1)\n" + " Baerts Matthieu, Remy Baptiste, Van Wallendael " + "Nicolas and Verhaeghe Helene\n\n" + "Authors: (v2+)\n" + " Baerts Matthieu, Van Wallendael Nicolas\n\n" + "Graphisms:\n" + " Van Wallendael Julien\n\n" + "Music and sounds:\n" + " Adans Paschal (adanspaschal.gmail.com) and" + " Klez (The gateway - SpaceShip level)\n\n" + "Credits & License:\n" + " Bouboule was developed during the course" + " FSAB1509 - Projet Informatique (Yves Deville, Universite" + " Catholique de Louvain, Belgium), 2012-2013.\n\n" + "Open-Source GPL3 license and developed with LibGDX" + " (Free and Open-Source game development framework under" + " Apache License 2.0)."; int iVersion = Gdx.app.getVersion(); if (iVersion > 0) cAboutText += "\n\nVersion: " + iVersion; Label label = new Label(cAboutText, getSkin(), "osaka-font", Color.WHITE); // not on the border label.setWidth(GlobalSettings.APPWIDTH - 20 * GlobalSettings.HD); label.setHeight(GlobalSettings.APPHEIGHT - 20 * GlobalSettings.HD); label.setPosition(10 * GlobalSettings.HD, 10 * GlobalSettings.HD); label.setAlignment(Align.center);//from w w w . j a v a2 s . com label.setWrap(true); // return to the next lines // filters // label.getStyle().font.getRegion().getTexture().setFilter(TextureFilter.Linear, TextureFilter.Linear); // label.setFillParent(true); used all the screen: too large stage.addActor(label); //Create all Buttons addBackButton(false); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.AbstractScreen.java
License:Open Source License
protected Label addLabel(String text, String fontName, float scale, Color color, int x, int y) { Label label = new Label(text, getSkin(), fontName, color); label.setX(x);//from w w w .jav a 2 s . c o m label.setY(y); if (scale != 0 && scale != 1) label.setFontScale(scale); stage.addActor(label); return label; }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.GameOverScreen.java
License:Open Source License
private void showHighScore() { highScoreLabel = new Label("HIGH SCORE", getSkin(), "darktimes-font", new Color(0.309f, 0.584f, .796f, 1f)); highScoreLabel.setFontScale(.6f);/*from ww w . j av a 2 s .c o m*/ highScoreLabel.setAlignment(Align.center); highScoreLabel.setWidth(GlobalSettings.APPWIDTH); highScoreLabel.setY(GlobalSettings.ISHD ? 930 : 560); highScoreLabel.setTouchable(null); // we can click through it stage.addActor(highScoreLabel); ActionHighScore highScoreAction = new ActionHighScore(); stage.addAction(highScoreAction); highScoreAction.setActor(highScoreLabel); }
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.MenuScreen.java
License:Open Source License
@Override public void show() { super.show(); // Set Background addBackGroundShift("GdxMenus/main/mainmenubg.jpg"); // Add Button image addBackGround("GdxMenus/main/mainmenubuttons.png"); // Create the 2 Bouboules out of the screen final Image imgBoubouleR = addImage("GdxMenus/main/boubouleright.png", GlobalSettings.APPWIDTH, 1f); final Image imgBoubouleL = addImage("GdxMenus/main/boubouleleft.png", -GlobalSettings.APPWIDTH, 1f); // add action on the bouboule final ActionBouboul actionbouL = new ActionBouboul(false); this.stage.addAction(actionbouL); actionbouL.setActor(imgBoubouleL);// www .j a va 2s. c o m final ActionBouboul actionbouR = new ActionBouboul(true); this.stage.addAction(actionbouR); actionbouR.setActor(imgBoubouleR); // add the title title = new Label("BOUBOULE", getSkin(), "darktimes-font", new Color(.388f, .733f, .984f, 1f)); title.setAlignment(Align.center); // center title.setWidth(GlobalSettings.APPWIDTH); // title.setColor(.2f, .7098f, .898f, 1f); // android color // add the title in a table in order to rotate it. Table tableTitle = new Table(); tableTitle.add(title); tableTitle.setTransform(true); tableTitle.setWidth(GlobalSettings.APPWIDTH); // all the width tableTitle.setX(0); tableTitle.setY((int) (1050 * GlobalSettings.HD) - GlobalSettings.SHIFT_BG_HEIGHT / 2); tableTitle.setOrigin(GlobalSettings.APPWIDTH / 2, tableTitle.getHeight() / 2); // at the center stage.addActor(tableTitle); // add action on the title final ActionTitle actiontitle = new ActionTitle(); this.stage.addAction(actiontitle); actiontitle.setActor(tableTitle); // Add 5 button transparent Button playButton, paramButton, scoreButton, boubouleButton, titleButton; if (GlobalSettings.ISHD) { playButton = createButton("transparent", 690, 250, 312, 1150); paramButton = createButton("transparent", 690, 250, 312, 887); scoreButton = createButton("transparent", 690, 250, 312, 615); boubouleButton = createButton("transparent", 1000, 600, 200, 0); titleButton = createButton("transparent", 1000, 1000, 200, 1450); } else { playButton = createButton("transparent", 430, 160, 200, 725); paramButton = createButton("transparent", 430, 160, 200, 555); scoreButton = createButton("transparent", 430, 160, 200, 385); boubouleButton = createButton("transparent", 500, 350, 200, 0); titleButton = createButton("transparent", 500, 500, 200, 885); } // Listener for the button playButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (GlobalSettings.GAME.isPlayingGame()) setScreenWithFading(null); else setScreenWithFading(new WorldScreen()); } }); paramButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { setScreenWithFading(new ParamScreen()); } }); scoreButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { if (GlobalSettings.GAMECENTER != null) { GlobalSettings.GAMECENTER.showLeaderboard(); } else { Dialog dialog = new Dialog(" HighScore ", getSkin(), "default") { // improved default skin? // protected void result(Object object) {} // Just hide the dialog }.text("\n" + getHighScoreText() + " ").button(" Close ", null).show(stage); dialog.setX((GlobalSettings.APPWIDTH - dialog.getWidth()) / 2); } } }); boubouleButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { final ActionBouboul actionbouL = new ActionBouboul(false); actionbouL.init(); stage.addAction(actionbouL); actionbouL.setActor(imgBoubouleL); final ActionBouboul actionbouR = new ActionBouboul(true); actionbouR.init(); stage.addAction(actionbouR); actionbouR.setActor(imgBoubouleR); } }); titleButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { actiontitle.switchName(); } }); }
From source file:com.flaiker.reaktio.screens.AbstractScreen.java
License:Open Source License
public AbstractScreen(Reaktio reaktio, Skin skin) { this.batch = new SpriteBatch(); this.reaktio = reaktio; this.uiStage = new Stage(new StretchViewport(SCREEN_WIDTH, SCREEN_HEIGHT)); this.skin = skin != null ? skin : new Skin(Gdx.files.internal("skin/uiskin.json")); this.fpsLabel = new Label("", this.skin, "arial", Color.WHITE); this.backgroundImage = new Image(new Texture((Gdx.files.internal("bg.png")))); camera = new OrthographicCamera(); camera.setToOrtho(false, SCREEN_WIDTH, SCREEN_HEIGHT); }
From source file:com.flaiker.reaktio.screens.MenuScreen.java
License:Open Source License
@Override public void show() { super.show(); if (demoGame == null) demoGame = new Game(GameSettings.newDemoGameSettings(), SCREEN_WIDTH, SCREEN_HEIGHT, camera); Table table = new Table(skin); table.setFillParent(true);/*from www . java2 s . com*/ uiStage.addActor(table); table.add().padBottom(50).row(); Label titleLabel = new Label("Reaktio", skin, "digital7-92", Color.WHITE); //titleLabel.setFontScale(2); table.add(titleLabel).spaceBottom(5).align(1); table.row(); table.add("A reaction test game").align(1).spaceBottom(20); table.row(); // register the button "Start" TextButton startGameButton = new TextButton("START", skin); startGameButton.setColor(1, 1, 1, 0.9f); startGameButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); reaktio.setScreen(new ModeSelectionScreen(reaktio, demoGame, skin)); } }); table.add(startGameButton).expand().fill().pad(100, 100, 100, 100); table.row(); // register the button "Highscore" TextButton highscoreButton = new TextButton("HIGHSCORE", skin); highscoreButton.setColor(1, 1, 1, 0.9f); highscoreButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); //reaktio.setScreen(new HighscoreScreen(reaktio, demoGame, skin)); } }); table.add(highscoreButton).expand().fill().pad(0, 100, 100, 100); table.row(); // register the button "Options" TextButton optionsButton = new TextButton("OPTIONS", skin); optionsButton.setColor(1, 1, 1, 0.9f); optionsButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); reaktio.setScreen(new OptionsScreen(reaktio, demoGame, skin)); } }); table.add(optionsButton).expand().fill().pad(0, 100, 100, 100).row(); table.add(new Label("www.flaiker.com", skin)); Gdx.input.setInputProcessor(uiStage); }
From source file:com.flaiker.reaktio.screens.ModeSelectionScreen.java
License:Open Source License
@Override public void show() { super.show(); if (demoGame == null) demoGame = new Game(GameSettings.newDemoGameSettings(), SCREEN_WIDTH, SCREEN_HEIGHT, camera); Table table = new Table(skin); table.setFillParent(true);/* www . j a v a 2s . c om*/ uiStage.addActor(table); table.add().padBottom(50).row(); Label titleLabel = new Label("Reaktio", skin, "digital7-92", Color.WHITE); //titleLabel.setFontScale(2); table.add(titleLabel).spaceBottom(5).align(1); table.row(); table.add("Select a Gamemode").align(1).spaceBottom(20); table.row(); // register the button "Timelimit" TextButton timelimitButton = new TextButton("Timelimit", skin); timelimitButton.setColor(1, 1, 1, 0.9f); timelimitButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); reaktio.setScreen(new GameScreen(reaktio, GameSettings.newTimeLimitGameSettings(30, 2, 2), skin)); } }); table.add(timelimitButton).expand().fill().pad(0, 100, 100, 100); table.row(); // register the button "Continuous" TextButton continuousButton = new TextButton("Continuous", skin); continuousButton.setColor(1, 1, 1, 0.9f); continuousButton.addListener(new DefaultActorListener() { @Override public void touchUp(InputEvent event, float x, float y, int pointer, int button) { super.touchUp(event, x, y, pointer, button); reaktio.setScreen(new GameScreen(reaktio, GameSettings.newContinuousGameSettings(2, 2), skin)); } }); table.add(continuousButton).expand().fill().pad(100, 100, 100, 100); table.row(); table.add(new Label("www.flaiker.com", skin)); Gdx.input.setInputProcessor(uiStage); }
From source file:com.gcq.fivesecond.layer.AboutLayer.java
License:Apache License
/** * Build view elements.//from w ww . j a v a 2 s .c om * */ private void buildElements() { // --------------------------------------------------------------- // Background. // --------------------------------------------------------------- Image image = new Image(logo); image.setWidth(getWidth()); image.setHeight(getHeight()); // --------------------------------------------------------------- // Labels // --------------------------------------------------------------- urlLabel = new Label("www.netthreads.co.uk", skin, URL_LABEL_FONT, Color.WHITE); versionLabel = new Label(FiveSecondGame.VERSION_TEXT, skin, URL_LABEL_FONT, Color.WHITE); // --------------------------------------------------------------- // Table // --------------------------------------------------------------- table = new Table(); table.size((int) getWidth(), (int) getHeight()); table.row(); table.add(urlLabel).expandY().expandX(); table.row(); table.add(image); table.row(); table.add(versionLabel).expandY().expandX(); table.pack(); table.setFillParent(true); addActor(table); }
From source file:com.gcq.fivesecond.layer.SettingsLayer.java
License:Apache License
/** * Build view elements.//from w w w . j ava2 s .c o m * */ private void buildElements() { // --------------------------------------------------------------- // Background. // --------------------------------------------------------------- Image image = new Image(background); image.setWidth(getWidth()); image.setHeight(getHeight()); addActor(image); // --------------------------------------------------------------- // Elements // --------------------------------------------------------------- final Label titleLabel = new Label("?", skin, TITLE_FONT, Color.YELLOW); final Label level = new Label("", skin); final CheckBox checkBox = new check(textureCache, AppTextureDefinitions.TEXTURE_CHECKBOX_ON, AppTextureDefinitions.TEXTURE_CHECKBOX_OFF).getCheckBox(""); GameProperties gp = FiveSecondGame.dbm.getProperties(); checkBox.setChecked(gp.isAudioOn()); final Label soundLabel = new Label("", skin); final Slider slider = new Slider(0, 10, 1, false, skin); slider.setValue(gp.getVolume() * 10); final CheckBox radio_low = new check(textureCache, AppTextureDefinitions.TEXTURE_RADIO_LOW_ON, AppTextureDefinitions.TEXTURE_RADIO_LOW_ON).getCheckBox(""), radio_mid = new check(textureCache, AppTextureDefinitions.TEXTURE_RADIO_MID_ON, AppTextureDefinitions.TEXTURE_RADIO_MID_OFF).getCheckBox(""), radio_hi = new check(textureCache, AppTextureDefinitions.TEXTURE_RADIO_HI_ON, AppTextureDefinitions.TEXTURE_RADIO_HI_OFF).getCheckBox(""); int dif = gp.getDifficulty(); if (dif == 15) { radio_hi.setChecked(true); radio_mid.setChecked(true); } else if (dif == 10) { radio_hi.setChecked(false); radio_mid.setChecked(true); } else { radio_hi.setChecked(false); radio_mid.setChecked(false); } // --------------------------------------------------------------- // Table // --------------------------------------------------------------- table = new Table(); table.setSize(getWidth(), getHeight()); table.row().height(150f); table.add(titleLabel).colspan(3); table.row().height(70f); table.add(level).colspan(3); table.row().height(70f); table.add(radio_low); table.add(radio_mid).uniform().padLeft(-16f).width(158f); table.add(radio_hi).uniform().padLeft(-14f).width(158f); table.row().height(70f); table.add(soundLabel).colspan(3); table.row().height(70f); table.add(checkBox).left().padLeft(5f); table.add(slider).colspan(2).width(245f); table.setTransform(true); table.setOrigin(table.getPrefWidth() / 2, table.getPrefHeight() / 2); addActor(table); // Handlers checkBox.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { boolean setting = checkBox.isChecked(); // gameProperties.setAudioOn(setting); FiveSecondGame.dbm.updateAudioOn(setting); } }); radio_low.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { radio_hi.setChecked(false); radio_mid.setChecked(false); // gameProperties.setDifficulty(1); FiveSecondGame.dbm.updateDifficulty(5); } }); radio_mid.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { radio_hi.setChecked(false); radio_mid.setChecked(true); // gameProperties.setDifficulty(2); FiveSecondGame.dbm.updateDifficulty(10); } }); radio_hi.addListener(new ClickListener() { @Override public void clicked(InputEvent event, float x, float y) { boolean hi = radio_hi.isChecked(); if (hi) { radio_mid.setChecked(true); // gameProperties.setDifficulty(3); FiveSecondGame.dbm.updateDifficulty(15); } else { // gameProperties.setDifficulty(2); FiveSecondGame.dbm.updateDifficulty(10); } } }); slider.addListener(new ChangeListener() { @Override public void changed(ChangeEvent event, Actor actor) { Slider slider = (Slider) actor; FiveSecondGame.dbm.updateVolume(slider.getValue() / 10); // if (slider.getValue() == 0) { // gameProperties.setVolume(0); // // } else { // gameProperties.setVolume(slider.getValue() / 10); // } } }); }
From source file:com.mygdx.java.screens.MenuScreen.java
License:Apache License
private Table buildOptWinAudioSettings() { Table tbl = new Table(); // + Title: "Audio" tbl.pad(10, 10, 0, 10);/* www . j ava2 s. c om*/ tbl.add(new Label("Audio", skinLibgdx, "default-font", Color.ORANGE)).colspan(3); tbl.row(); tbl.columnDefaults(0).padRight(10); tbl.columnDefaults(1).padRight(10); // + Checkbox, "Sound" label, sound volume slider chkSound = new CheckBox("", skinLibgdx); tbl.add(chkSound); tbl.add(new Label("Sound", skinLibgdx)); sldSound = new Slider(0.0f, 1.0f, 0.1f, false, skinLibgdx); tbl.add(sldSound); tbl.row(); // + Checkbox, "Music" label, music volume slider chkMusic = new CheckBox("", skinLibgdx); tbl.add(chkMusic); tbl.add(new Label("Music", skinLibgdx)); sldMusic = new Slider(0.0f, 1.0f, 0.1f, false, skinLibgdx); tbl.add(sldMusic); tbl.row(); return tbl; }