List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Label getTextBounds
public TextBounds getTextBounds()
From source file:be.ac.ucl.lfsab1509.bouboule.game.screen.GameOverScreen.java
License:Open Source License
@Override public void show() { super.show(); // Set Background addBackGroundShift("GdxMenus/gameover/gameoverbg.jpg"); //Add buttons addBackGround("GdxMenus/gameover/gameoverbuttons.png"); // Create all Buttons - Play Button Button restartButton = GlobalSettings.ISHD ? createButton("transparent", 475, 147, 103, 814) : createButton("transparent", 290, 90, 63, 497); Button menuButton = GlobalSettings.ISHD ? createButton("transparent", 475, 147, 734, 814) : createButton("transparent", 290, 90, 448, 497); restartButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { setScreenWithFading(new WorldScreen()); }//from w w w. j av a 2 s .com }); menuButton.addListener(new ClickListener() { public void clicked(InputEvent event, float x, float y) { setScreenWithFading(new MenuScreen()); } }); // Set Font for end Score float fScaleFont = GlobalSettings.ISHD ? 1f : 0.7f; int iY = GlobalSettings.ISHD ? 1130 : 650; int endScore = GlobalSettings.PROFILE.getEndGameScore(); String text = endGame ? "END - " + endScore : Integer.toString(endScore); Label label = addLabel(text, "chinyen-font", fScaleFont, new Color(1f, 1f, 1f, 1f), 0, iY); label.setX(GlobalSettings.APPWIDTH / 2f - label.getTextBounds().width / 2f); if (GlobalSettings.PROFILE.isNewHighScore()) showHighScore(); }
From source file:com.coder5560.game.ui.MyDialog.java
License:Apache License
/** Adds the given Label to the content table */ public MyDialog text(Label label) { contentTable.add(label).width(label.getTextBounds().width).pad(20); return this; }
From source file:com.digitale.utils.Actors.java
License:Open Source License
public static Actor topToast(final String text, final float time, final Skin skin) { final Window window = new Window("", skin); final Color windowColor = new Color(1, 0, 0, 1); window.setMovable(false);/*from w w w . jav a 2s .co m*/ window.defaults().spaceBottom(5); Label toastLabel = new Label(text, skin); toastLabel.setAlignment(Align.LEFT); toastLabel.setWrap(true); window.row().fillX().expandX(); window.add(toastLabel).fillX().padLeft(10); window.invalidate(); window.width = Gdx.app.getGraphics().getWidth() * 0.95f; window.height = toastLabel.getTextBounds().height + 20 + window.getStyle().titleFont.getLineHeight(); window.x = Gdx.app.getGraphics().getWidth() * 0.5f - window.width * 0.5f; float outsideY = Gdx.app.getGraphics().getHeight() + window.height; float insideY = Gdx.app.getGraphics().getHeight() - window.height + window.getStyle().titleFont.getLineHeight(); window.y = outsideY; final TimelineAnimation timelineAnimation = Builders.animation( // Builders.timeline() // .value(Builders.timelineValue(window, Scene2dConverters.actorPositionTypeConverter) // .keyFrame(0f, new float[] { window.x, outsideY }, // InterpolationFunctions.linear(), InterpolationFunctions.easeIn()) // .keyFrame(1f, new float[] { window.x, insideY }) // .keyFrame(4f, new float[] { window.x, insideY }, // InterpolationFunctions.linear(), InterpolationFunctions.easeOut()) // .keyFrame(5f, new float[] { window.x, outsideY }) // ) // ) // .started(true) // .delay(0f) // .speed(5f / time) // .build(); window.action(new ActionAdapter() { @Override public void act(float delta) { timelineAnimation.update(delta); if (timelineAnimation.isFinished()) { window.getStage().removeActor(window); } } }); return window; }
From source file:com.digitale.utils.Actors.java
License:Open Source License
public static Actor bottomToast(final String text, final float time, Skin skin) { skin = new Skin(Gdx.files.internal("data/dialogskin.json"), Gdx.files.internal("data/dialogskin.png")); final Window window = new Window("", skin); window.setMovable(false);//from w w w. j a v a 2 s.c o m window.defaults().spaceBottom(5); Label toastLabel = new Label(text, skin); toastLabel.setAlignment(Align.LEFT); toastLabel.setWrap(true); window.row().fillX().expandX(); window.add(toastLabel).fillX().padLeft(10); window.invalidate(); window.width = Gdx.graphics.getWidth() * 0.5f; window.height = toastLabel.getTextBounds().height * 5 + window.getStyle().titleFont.getLineHeight(); window.x = Gdx.graphics.getWidth() * 0.5f - window.width * 0.5f; float outsideY = 0 - window.height; float insideY = -20 + window.height + window.getStyle().titleFont.getLineHeight(); window.y = outsideY; final TimelineAnimation timelineAnimation = Builders.animation( // Builders.timeline() // .value(Builders.timelineValue(window, Scene2dConverters.actorPositionTypeConverter) // .keyFrame(0f, new float[] { window.x, outsideY }, // InterpolationFunctions.linear(), InterpolationFunctions.easeIn()) // .keyFrame(.5f, new float[] { window.x, insideY }) // .keyFrame(4f, new float[] { window.x, insideY }, // InterpolationFunctions.linear(), InterpolationFunctions.easeOut()) // .keyFrame(4.5f, new float[] { window.x, outsideY }) // ) // ) // .started(true) // .delay(0f) // .speed(5f / time) // .build(); window.action(new ActionAdapter() { @Override public void act(float delta) { timelineAnimation.update(delta); if (timelineAnimation.isFinished()) { window.getStage().removeActor(window); } } }); return window; }
From source file:net.ivang.axonix.main.screens.GameScreen.java
License:Apache License
@Subscribe @SuppressWarnings("unused") public void showObtainedPoints(ObtainedPointsFact fact) { // text//from ww w .j av a 2 s . c o m int points = fact.getPoints(); Label label = (points <= ObtainedPointsFact.QUANTITY_3) ? getPointsLabel() : getBigPointsLabel(); label.setText(Integer.toString(points)); // position float x = fact.getX(); float y = fact.getY(); if (fact.isSubtractBounds()) { x -= label.getTextBounds().width; } label.setPosition(x, y); // events SequenceAction fadeInFadeOut = Actions.sequence(Actions.visible(true), Actions.fadeIn(0.2f), Actions.delay(1f), Actions.fadeOut(0.3f), Actions.visible(false)); ParallelAction fadeAndMove = Actions.parallel(Actions.moveTo(x, y + fact.getDeltaY(), 1.5f), fadeInFadeOut); label.clearActions(); label.addAction(fadeAndMove); }