From 3f72675a5048dd9b47e8cef80fd07ed5e4aeaa10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 17 Sep 2014 09:54:28 +0200 Subject: do not push the same vector again --- core/src/ch/asynk/tankontank/engine/PawnImage.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/PawnImage.java b/core/src/ch/asynk/tankontank/engine/PawnImage.java index 77ef752..acb09a9 100644 --- a/core/src/ch/asynk/tankontank/engine/PawnImage.java +++ b/core/src/ch/asynk/tankontank/engine/PawnImage.java @@ -33,15 +33,17 @@ public class PawnImage extends Image implements Pawn setPosition(x, y); if (r != Tile.Orientation.KEEP) setRotation(r.v); setZIndex(z); - path.push(new Vector3(x, y, r.v)); + Vector3 v = new Vector3(x, y, r.v); + if ((path.size() == 0) || (!v.equals(path.getFirst()))) + path.push(new Vector3(x, y, r.v)); } public void resetMoves(Runnable cb) { - final Pawn self = this; final Vector3 finalPos = path.getLast(); SequenceAction seq = new SequenceAction(); + while(path.size() != 0) { Vector3 v = path.pop(); seq.addAction(Actions.moveTo(v.x, v.y, MOVE_TIME)); @@ -56,7 +58,7 @@ public class PawnImage extends Image implements Pawn } })); - // map set z index and push me in hex stack + // the map must finalize this move seq.addAction(Actions.run(cb)); addAction(seq); -- cgit v1.1-2-g2b99