diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-10-18 19:58:17 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-10-18 19:58:17 +0200 |
commit | 99f34a61fef2010b5683ff159becb63bfa68b83f (patch) | |
tree | 595504db8de907382d17ad851963907228337ac9 /test/src/ch/asynk/gdx | |
parent | 07f901d3de16d25dcd8d21f205ba891e7fa337b0 (diff) | |
download | gdx-boardgame-99f34a61fef2010b5683ff159becb63bfa68b83f.zip gdx-boardgame-99f34a61fef2010b5683ff159becb63bfa68b83f.tar.gz |
AnimationScreen : use Tile Overlay on MoveAnimation
Diffstat (limited to 'test/src/ch/asynk/gdx')
-rw-r--r-- | test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java index 9fd6d68..9e7da45 100644 --- a/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java +++ b/test/src/ch/asynk/gdx/boardgame/test/AnimationsScreen.java @@ -25,6 +25,7 @@ public class AnimationsScreen extends AbstractScreen private final Piece panzer; private final Camera cam; private final Board board; + private final Path path; private final AnimationSequence animations; public AnimationsScreen(final GdxBoardTest app) @@ -44,15 +45,24 @@ public class AnimationsScreen extends AbstractScreen cam.zoom(-0.3f); cam.centerOnWorld(); + path = buildPath(app); + animations = AnimationSequence.obtain(10); animations.add(BounceAnimation.obtain(panzer, 2f, 3f, -1)); animations.add(DelayAnimation.obtain(panzer, 1f)); - animations.add(MoveAnimation.obtain(panzer, buildPath(), 2f, (p,path) -> System.err.println(String.format("%s -> %s", path.from(), path.to())))); + animations.add(MoveAnimation.obtain(panzer, path, 2f, (p,path) -> { + Tile from = path.from(); + Tile to = path.to(); + System.err.println(String.format("%s -> %s", from, to)); + from.enableOverlay(2, false); + if (to != null) to.enableOverlay(2, true); + })); animations.add(DelayAnimation.obtain(panzer, 1f)); } - private Path buildPath() + private Path buildPath(final GdxBoardTest app) { + Tile.defaultOverlay = app.assets.getAtlas(app.assets.HEX_OVERLAYS); Vector2 v = new Vector2(); Path path = Path.obtain(); path.ensureCapacity(10); @@ -109,6 +119,9 @@ public class AnimationsScreen extends AbstractScreen batch.setProjectionMatrix(cam.combined); batch.begin(); batch.draw(map, 0, 0); + for (int i = 0; i < path.size(); i++) { + path.get(i).draw(batch); + } animations.draw(batch); batch.end(); } |