List of usage examples for com.badlogic.gdx.scenes.scene2d.actions RunnableAction RunnableAction
RunnableAction
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);// w w w.ja va 2s . c om } }, 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.ray3k.skincomposer.dialog.DialogLoading.java
License:Open Source License
@Override public Dialog show(Stage stage) { Dialog dialog = super.show(stage); RunnableAction runnableAction = new RunnableAction(); runnableAction.setRunnable(() -> { if (runnable != null) { runnable.run();// w w w . j av a 2 s . c o m } hide(); }); Action action = new SequenceAction(new DelayAction(.5f), runnableAction); addAction(action); return dialog; }
From source file:com.ray3k.skincomposer.RootTable.java
License:Open Source License
private void display(final String text) { SequenceAction sequenceAction = new SequenceAction(); if (statusLabel.isVisible()) { statusLabel.clearActions();// w w w . j a va2 s .co m AlphaAction alphaAction = new AlphaAction(); alphaAction.setAlpha(0.0f); alphaAction.setDuration(.25f); sequenceAction.addAction(alphaAction); RunnableAction runnableAction = new RunnableAction(); runnableAction.setRunnable(() -> { statusLabel.setText(text); }); sequenceAction.addAction(runnableAction); alphaAction = new AlphaAction(); alphaAction.setAlpha(1.0f); alphaAction.setDuration(.25f); sequenceAction.addAction(alphaAction); DelayAction delayAction = new DelayAction(); delayAction.setDuration(3.0f); sequenceAction.addAction(delayAction); alphaAction = new AlphaAction(); alphaAction.setAlpha(0.0f); alphaAction.setDuration(1.5f); sequenceAction.addAction(alphaAction); VisibleAction visibleAction = new VisibleAction(); visibleAction.setVisible(false); sequenceAction.addAction(visibleAction); } else { statusLabel.setText(text); statusLabel.clearActions(); statusLabel.setVisible(true); AlphaAction alphaAction = new AlphaAction(); alphaAction.setAlpha(1.0f); alphaAction.setDuration(.5f); sequenceAction.addAction(alphaAction); DelayAction delayAction = new DelayAction(); delayAction.setDuration(3.0f); sequenceAction.addAction(delayAction); alphaAction = new AlphaAction(); alphaAction.setAlpha(0.0f); alphaAction.setDuration(1.5f); sequenceAction.addAction(alphaAction); VisibleAction visibleAction = new VisibleAction(); visibleAction.setVisible(false); sequenceAction.addAction(visibleAction); } statusLabel.addAction(sequenceAction); }
From source file:de.longri.cachebox3.gui.animations.actor_animations.GestureHelpAnimation.java
License:Open Source License
public GestureHelpAnimation(final Vector2 start, final Vector2 end) { // create finger actor final Image finger = new Image(CB.getSprite("finger")); final Image fingerClick = new Image(CB.getSprite("finger_click")); //set start and end to finger of hand float fingerY = finger.getHeight() * 0.7f; float fingerX = finger.getWidth() * 0.2f; start.y -= fingerY;//from w ww .j a va2 s .c o m start.x += fingerX; end.y -= fingerY; end.x += fingerX; finger.addAction(Actions.moveTo(start.x, start.y)); fingerClick.addAction(Actions.moveTo(start.x, start.y)); this.addAction(new AddActorAction(finger)); this.addAction(Actions.delay(0.7f)); this.addAction(Actions.removeActor(finger)); this.addAction(new AddActorAction(fingerClick)); RunnableAction runnableAction = new RunnableAction(); runnableAction.setRunnable(new Runnable() { @Override public void run() { RunnableAction runnableAction = new RunnableAction(); runnableAction.setRunnable(new Runnable() { @Override public void run() { fingerClick.addAction(Actions.sequence(Actions.delay(0.7f), Actions.removeActor())); } }); Action action = Actions.sequence(Actions.moveTo(end.x, end.y, 1.0f, Interpolation.pow2), runnableAction); fingerClick.addAction(action); finger.addAction(Actions.moveTo(end.x, end.y)); } }); this.addAction(runnableAction); }