Java Code Examples for com.badlogic.gdx.scenes.scene2d.ui.Image#addAction()
The following examples show how to use
com.badlogic.gdx.scenes.scene2d.ui.Image#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: CommonShotVisualizer.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public IFuture<Void> visualize(final T result) { final Future<Void> future = Future.make(); final WorldObjectView actorView = visualizer.viewController.getView(result.getActor()); WorldObjectView targetView = visualizer.viewController.getView(result.getTarget()); visualizer.viewController.world.dispatcher.dispatch(ResultVisualizer.VISUALIZE_ATTACK, result.getActor()); Vector2 direction = tmp .set(result.getTarget().getX(), result.getTarget().getY()) .sub(result.getActor().getX(), result.getActor().getY()); float dx = targetView.getX() - actorView.getX(); float dy = targetView.getY() - actorView.getY(); visualizer.viewController.scroller.centerOn(result.getTarget()); final Image arrow = new Image(Config.skin,"animation/" + result.getAbility().name + "-shot"); arrow.setPosition(actorView.getX(), actorView.getY()); visualizer.viewController.effectLayer.addActor(arrow); arrow.setOrigin(13, 14); arrow.setRotation(direction.angle() - 45); arrow.addAction(Actions.sequence( Actions.moveBy(dx, dy, tmp.set(dx, dy).len() * 0.002f), Actions.run(new Runnable() { @Override public void run() { SoundManager.instance.playSoundIfExists(result.getAbility().soundName); arrow.remove(); future.happen(); } }) )); return future; }
Example 2
Source File: BeamVisualizer.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
@Override public IFuture<Void> visualize(ITargetOwner result) { final Future<Void> future = new Future<Void>(); SoundManager.instance.playSoundIfExists(soundName); Image image = new Image(Config.skin, "effect-luck-image"); image.setColor(color); image.setScale(0, 0); image.setOrigin(image.getWidth() / 2, image.getHeight() / 2); image.setPosition( result.getTarget().getX() * ViewController.CELL_SIZE + (ViewController.CELL_SIZE - image.getWidth()) * 0.5f, result.getTarget().getY() * ViewController.CELL_SIZE + (ViewController.CELL_SIZE - image.getHeight()) * 0.5f + 6 ); visualizer.viewController.effectLayer.addActor(image); image.addAction( Actions.sequence( Actions.parallel( Actions.scaleTo(0.75f, 0.75f, 0.5f, Interpolation.sine), Actions.rotateBy(135, 0.5f) ), Actions.parallel( Actions.scaleTo(0, 0, 0.5f, Interpolation.sine), Actions.rotateBy(135, 0.5f) ), Actions.run(future), Actions.removeActor() ) ); return future; }
Example 3
Source File: ViewController.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void addBackgroundObject(boolean anywhere) { final Image image = new Image(backgroundDrawables.random()); backgroundLayer.addActor(image); float scale = 0.5f * MathUtils.random(1, 2); image.setSize(image.getPrefWidth() * scale, image.getPrefHeight() * scale); image.setRotation(MathUtils.random(0, 1) * 180); image.getColor().a = MathUtils.random(0.1f, 0.3f); float w = Math.max(world.stage.getWidth(), root.getWidth() + ViewScroller.LEFT + ViewScroller.RIGHT); float h = Math.max(world.stage.getHeight(), root.getHeight() + ViewScroller.TOP + ViewScroller.BOTTOM); if (anywhere) image.setPosition(-root.getX() + w * MathUtils.random(), -root.getY() + h * MathUtils.random()); else image.setPosition(-root.getX() - image.getWidth(), -root.getY() + h * MathUtils.random()); image.addAction(Actions.sequence( Actions.moveBy(w + image.getWidth() - image.getX(), 0, 15 + MathUtils.random(6)), Actions.run(new Runnable() { @Override public void run() { image.remove(); addBackgroundObject(false); } }) )); }
Example 4
Source File: RewardWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void rotateContinuously(final Image back) { back.addAction(Actions.sequence( Actions.rotateBy(-360, 6f, Interpolation.linear), Actions.run(new Runnable() { @Override public void run() { rotateContinuously(back); } }) )); }
Example 5
Source File: LevelUpWindow.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void rotateContinuously(final Image back) { back.addAction(Actions.sequence( Actions.rotateBy(-360, 6f, Interpolation.linear), Actions.run(new Runnable() { @Override public void run() { rotateContinuously(back); } }) )); }
Example 6
Source File: DieNet.java From dice-heroes with GNU General Public License v3.0 | 5 votes |
private void blink(final Image image) { image.addAction(Actions.sequence( Actions.alpha(0.4f, 0.5f), Actions.alpha(0f, 0.5f), Actions.run(new Runnable() { @Override public void run() { blink(image); } }) )); }
Example 7
Source File: IntroState.java From dice-heroes with GNU General Public License v3.0 | 4 votes |
@Override protected void init() { stage.getViewport().update(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); textureImage = new Texture("logo-image.png"); textureText = new Texture("logo-text.png"); final Image image = new Image(textureImage); image.setPosition(stage.getWidth() / 2 - image.getWidth() / 2, stage.getHeight() / 2 - image.getHeight() / 2); final Image text = new Image(textureText); text.setPosition(image.getX(), image.getY()); stage.addActor(image); stage.addActor(text); image.getColor().a = 0; text.getColor().a = 0; image.addAction(Actions.sequence( Actions.alpha(1, 0.3f), Actions.run(new Runnable() { @Override public void run() { text.addAction( Actions.sequence( Actions.alpha(1, 0.3f), Actions.delay(1.5f), Actions.run(new Runnable() { @Override public void run() { image.addAction(Actions.alpha(0, 0.3f)); text.addAction(Actions.sequence( Actions.alpha(0, 0.3f), Actions.run(new Runnable() { @Override public void run() { callback.onEnded(); } }) )); } }) ) ); } }) )); }
Example 8
Source File: SplashScreen.java From Codelabs with MIT License | 4 votes |
@Override public void show() { stage = new Stage(); /* Load splash image */ codelabsImage = new Image(new Texture( Gdx.files.internal("data/images/codelabs_splash.png"))); githubImage = new Image(new Texture( Gdx.files.internal("data/images/github_splash.png"))); /* Set the splash image in the center of the screen */ float width = Gdx.graphics.getWidth(); float height = Gdx.graphics.getHeight(); codelabsImage.setPosition((width - codelabsImage.getWidth()) / 2, (height - codelabsImage.getHeight()) / 2); /* Fade in the image and then swing it down */ codelabsImage.getColor().a = 0f; codelabsImage.addAction(Actions.sequence(Actions.fadeIn(0.5f), Actions .delay(1, Actions.fadeOut(0.5f)))); githubImage.setPosition((width - githubImage.getWidth()) / 2, (height - githubImage.getHeight()) / 2); /* Fade in the image and then swing it down */ githubImage.getColor().a = 0f; githubImage.addAction(Actions.delay(2, Actions.sequence(Actions.fadeIn(0.5f), Actions .delay(1, Actions.moveBy(0, -(height - githubImage.getHeight() / 2), 1, Interpolation.swingIn)), Actions.run(new Runnable() { @Override public void run() { /* Show main menu after swing out */ ((Game) Gdx.app.getApplicationListener()) .setScreen(new MainMenu()); } })))); stage.addActor(codelabsImage); stage.addActor(githubImage); }