diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-10-18 17:12:11 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-10-18 17:12:11 +0200 |
commit | 2420e7a8cb388a36094ce846760fa3a18bab2699 (patch) | |
tree | 3bc3e6f8a587ac3186054b4cf30d583ad62db116 /core | |
parent | 53037c2e2bba89d358ad128db84f7b52b6beae5f (diff) | |
download | gdx-boardgame-2420e7a8cb388a36094ce846760fa3a18bab2699.zip gdx-boardgame-2420e7a8cb388a36094ce846760fa3a18bab2699.tar.gz |
MoveAnimation : notify on start and end of animation
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/animations/MoveAnimation.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/animations/MoveAnimation.java b/core/src/ch/asynk/gdx/boardgame/animations/MoveAnimation.java index 823f7c6..4771590 100644 --- a/core/src/ch/asynk/gdx/boardgame/animations/MoveAnimation.java +++ b/core/src/ch/asynk/gdx/boardgame/animations/MoveAnimation.java @@ -59,6 +59,7 @@ public class MoveAnimation implements Animation, Pool.Poolable setNextMove(); percent = 0f; dp = 1f * speed; + notify = true; } private boolean setNextMove() @@ -77,7 +78,7 @@ public class MoveAnimation implements Animation, Pool.Poolable (dst.y - piece.getY()) * speed, (dr) * speed ); - notify = (dr == 0 ? true : false); + notify = (dr == 0 ? (cb != null) : false); return done; } @@ -100,18 +101,25 @@ public class MoveAnimation implements Animation, Pool.Poolable @Override public boolean animate(float delta) { + if (notify && percent == 0f) { + cb.onTileChange(piece, path); + notify = false; + } piece.translate(dt.x * delta, dt.y * delta); piece.rotate(dt.z * delta); percent += (dp * delta); - if (notify && cb != null && percent >= 0.5f) { + if (notify && percent >= 0.5f) { cb.onTileChange(piece, path); notify = false; } if (percent >= 1f) { piece.setPosition(dst.x, dst.y, dst.z); if (!setNextMove()) { - percent = 0f; + percent = 0.0001f; + } else if (notify) { + cb.onTileChange(piece, path); + notify = false; } } |