diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-10 11:58:06 +0200 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-10-10 11:58:06 +0200 | 
| commit | 118dfc1d77cbb566c3ed212d79cb29bfda7c99d9 (patch) | |
| tree | fa4d234e8c166918b7394444af9f9a5e23405917 /core | |
| parent | 2ec8db85412449125fb4918c80dcc71872a923bd (diff) | |
| download | RustAndDust-118dfc1d77cbb566c3ed212d79cb29bfda7c99d9.zip RustAndDust-118dfc1d77cbb566c3ed212d79cb29bfda7c99d9.tar.gz | |
Pawn: cleanup animations, must set prevPosition when rotate, no need to set finalPos on move
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/ch/asynk/tankontank/engine/Pawn.java | 34 | 
1 files changed, 11 insertions, 23 deletions
| diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index 6fe1540..9a2fcc1 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -166,44 +166,32 @@ public abstract class Pawn implements Drawable, Disposable      public AnimationSequence getRotateAnimation(Vector3 v)      { +        prevPosition.set(position);          AnimationSequence seq = AnimationSequence.get(2);          seq.addAnimation(MoveToAnimation.get(this, v, MOVE_TIME));          return seq;      } -    public AnimationSequence getRevertLastMoveAnimation() +    public AnimationSequence getMoveAnimation(ArrayList<Vector3> path)      { -        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); -            } -        })); +        prevPosition.set(position); +        AnimationSequence seq = AnimationSequence.get(path.size() + 2); +        for (Vector3 v : path) +            seq.addAnimation(MoveToAnimation.get(this, v, MOVE_TIME));          return seq;      } -    public AnimationSequence getMoveAnimation(ArrayList<Vector3> path) +    public AnimationSequence getRevertLastMoveAnimation()      { -        prevPosition.set(position); - -        int s = path.size(); -        final Vector3 finalPos = path.get(s - 1); - -        AnimationSequence seq = AnimationSequence.get(s + 3); - -        for (Vector3 v : path) { -            seq.addAnimation(MoveToAnimation.get(this, v, MOVE_TIME)); -        } - +        AnimationSequence seq = AnimationSequence.get(4); +        seq.addAnimation(MoveToAnimation.get(this, prevPosition, MOVE_TIME));          seq.addAnimation(RunnableAnimation.get(this, new Runnable() {              @Override              public void run() { -                setPosition(finalPos.x, finalPos.y, finalPos.z); +                revertPosition(); +                setPosition(position.x, position.y, position.z);              }          })); | 
