List of usage examples for com.badlogic.gdx.scenes.scene2d.ui Window getStyle
public WindowStyle getStyle()
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 ww w.j a va 2s . 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.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. ja va 2s .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; }