diff options
Diffstat (limited to 'core/src/ch')
-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; } } |