diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-10 08:58:26 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-10 08:58:26 +0200 |
commit | c7a5eade2b1f0bc168a6b31b9426c2b270972f41 (patch) | |
tree | 62b6c32693bc1a2a16d4138d4215e7cda20b6ff1 /core | |
parent | ad12a84586d0d0c7f6f0f74e7c6c44c16a1b290d (diff) | |
download | RustAndDust-c7a5eade2b1f0bc168a6b31b9426c2b270972f41.zip RustAndDust-c7a5eade2b1f0bc168a6b31b9426c2b270972f41.tar.gz |
Pawn: add prevPosition, revertPosition(), getRevertLastMoveAnimation()
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 15e4200..6fe1540 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -25,6 +25,7 @@ public abstract class Pawn implements Drawable, Disposable private static final float MOVE_TIME = 0.4f; private Vector3 position = new Vector3(0f, 0f, 0f); + private Vector3 prevPosition = new Vector3(0f, 0f, 0f); private Image image; private StackedImages overlays; @@ -70,6 +71,17 @@ public abstract class Pawn implements Drawable, Disposable return position; } + public Vector3 getPreviousPosition() + { + return prevPosition; + } + + private void revertPosition() + { + position.set(prevPosition); + prevPosition.set(0f, 0f, 0f); + } + public Vector2 getCenter() { float x = (image.getX() + (image.getWidth() / 2f)); @@ -160,8 +172,25 @@ public abstract class Pawn implements Drawable, Disposable return seq; } + public AnimationSequence getRevertLastMoveAnimation() + { + AnimationSequence seq = AnimationSequence.get(4); + seq.addAnimation(MoveToAnimation.get(this, prevPosition, MOVE_TIME)); + seq.addAnimation(RunnableAnimation.get(this, new Runnable() { + @Override + public void run() { + revertPosition(); + setPosition(position.x, position.y, position.z); + } + })); + + return seq; + } + public AnimationSequence getMoveAnimation(ArrayList<Vector3> path) { + prevPosition.set(position); + int s = path.size(); final Vector3 finalPos = path.get(s - 1); |