Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Label#addAction()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.Label#addAction() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BvBWorkspace.java From talos with Apache License 2.0 | 6 votes |
public void flyLabel (String text) { Label label = new Label(text, TalosMain.Instance().getSkin()); label.setPosition(getWidth()/2f - label.getPrefWidth()/2f, 0); addActor(label); label.addAction(Actions.fadeOut(0.4f)); label.addAction(Actions.sequence( Actions.moveBy(0, 100, 0.5f), Actions.run(new Runnable() { @Override public void run () { label.remove(); } }) )); }
Example 2
Source File: StringSpin.java From dice-heroes with GNU General Public License v3.0 | 6 votes |
private void addActions(final Label label, final int i, final int idx, final float speed, final float spinTime, final float endTime, final Runnable callback) { label.addAction(new Action() { private float totalTime = spinTime + i * endTime; @Override public boolean act(float delta) { totalTime -= delta; label.moveBy(0, -speed * delta); boolean finished = totalTime <= 0; if (finished) { label.setY(-(letters.length() - idx - 1) * lineHeight); if (i == labels.size - 1) { callback.run(); } } else { while (label.getY() < -letters.length() * lineHeight) { label.setY(label.getY() + letters.length() * lineHeight); } } return finished; } }); }
Example 3
Source File: AnimationHelper.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
public static void animateCounter(final Label label, final int from, final int to) { label.addAction(new TemporalAction(MathUtils.clamp(Math.abs(to - from) / 30f, 0.5f, 1.5f), new Interpolation.ExpOut(2, 3)) { @Override protected void update(float percent) { label.setText(String.valueOf((int) (from + (to - from) * percent))); } }); }
Example 4
Source File: CardViewSmall.java From Cardshifter with Apache License 2.0 | 5 votes |
@Override public void set(Object key, Object value) { if ("HEALTH".equals(key)) { Integer health = (Integer) value; Integer oldHealth = (Integer) properties.get(key); int diff = health - oldHealth; WidgetGroup grp = (WidgetGroup) table.getParent(); grp.layout(); if (diff != 0) { Vector2 pos = new Vector2(table.getWidth() / 2, table.getHeight() / 2); table.localToStageCoordinates(pos); final Label changeLabel = new Label(String.valueOf(diff), context.getSkin()); Gdx.app.log("Anim", "Create health animation at " + pos.x + ", " + pos.y); changeLabel.setPosition(pos.x, pos.y); if (diff > 0) { changeLabel.setColor(Color.GREEN); } else { changeLabel.setColor(Color.RED); } changeLabel.addAction(Actions.sequence(Actions.moveBy(0, this.screenHeight/8, 1.5f), Actions.run(new Runnable() { @Override public void run() { changeLabel.remove(); } }))); context.getStage().addActor(changeLabel); } } properties.put((String) key, value); cost.update(properties); stats.update(properties); }
Example 5
Source File: DefaultSceneScreen.java From bladecoder-adventure-engine with Apache License 2.0 | 4 votes |
void showUIText(Text t) { // Type UI texts will show at the same time that TextManagerUI texts. String style = t.style == null ? "ui-text" : t.style; Label msg = new Label(t.str, getUI().getSkin(), style); msg.setWrap(true); msg.setAlignment(Align.center, Align.center); if (t.color != null) msg.setColor(t.color); msg.setSize(msg.getWidth() + DPIUtils.getMarginSize() * 2, msg.getHeight() + DPIUtils.getMarginSize() * 2); stage.addActor(msg); unprojectTmp.set(t.x, t.y, 0); getWorld().getSceneCamera().scene2screen(getStage().getViewport(), unprojectTmp); float posx, posy; if (t.x == TextManager.POS_CENTER) { posx = (getStage().getViewport().getScreenWidth() - msg.getWidth()) / 2; } else if (t.x == TextManager.POS_SUBTITLE) { posx = DPIUtils.getMarginSize(); } else { posx = unprojectTmp.x; } if (t.y == TextManager.POS_CENTER) { posy = (getStage().getViewport().getScreenHeight() - msg.getHeight()) / 2; } else if (t.y == TextManager.POS_SUBTITLE) { posy = getStage().getViewport().getScreenHeight() - msg.getHeight() - DPIUtils.getMarginSize() * 3; } else { posy = unprojectTmp.y; } msg.setPosition(posx, posy); msg.getColor().a = 0; msg.addAction(sequence(Actions.fadeIn(0.4f, Interpolation.fade), Actions.delay(t.time, sequence(fadeOut(0.4f, Interpolation.fade), Actions.removeActor())))); }