summaryrefslogtreecommitdiffstats
path: root/core/src/ch
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2014-10-03 17:28:40 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2014-10-03 17:28:40 +0200
commit815686901083acc1d416bcdc3c82296761875136 (patch)
tree1ff2797d2270acf9c213e45aba202e86bd0d879b /core/src/ch
parentddbdc3cb8a81a83dddf789ae84461b620b4f109f (diff)
downloadRustAndDust-815686901083acc1d416bcdc3c82296761875136.zip
RustAndDust-815686901083acc1d416bcdc3c82296761875136.tar.gz
Board: use getHexAt(pawn.getCenter()) to avoid wrong hex if image is big
Diffstat (limited to 'core/src/ch')
-rw-r--r--core/src/ch/asynk/tankontank/engine/Board.java18
1 files changed, 11 insertions, 7 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java
index c98682d..7ebece7 100644
--- a/core/src/ch/asynk/tankontank/engine/Board.java
+++ b/core/src/ch/asynk/tankontank/engine/Board.java
@@ -458,7 +458,7 @@ public abstract class Board implements Disposable
// public void movePawnTo(Pawn pawn, GridPoint2 coords, Orientation o)
// {
- // removePawnFrom(pawn, getHexAt(pawn.getLastPosition()));
+ // removePawnFrom(pawn, getHexAt(pawn.getCenter()));
// pushPawnAt(pawn, coords);
// Vector2 pos = getPawnPosAt(pawn, coords, null);
@@ -467,15 +467,13 @@ public abstract class Board implements Disposable
public void movePawn(final Pawn pawn, Vector<Vector3> path)
{
- removePawnFrom(pawn, getHexAt(pawn.getLastPosition()));
-
- final Vector3 finalPos = path.get(path.size() - 1);
+ removePawnFrom(pawn, getHexAt(pawn.getCenter()));
AnimationSequence seq = pawn.getMoveAnimation(path);
seq.addAnimation(RunnableAnimation.get(pawn, new Runnable() {
@Override
public void run() {
- pushPawnAt(pawn, getHexAt(finalPos));
+ pushPawnAt(pawn, getHexAt(pawn.getCenter()));
}
}));
addPawnAnimation(pawn, seq);
@@ -483,19 +481,25 @@ public abstract class Board implements Disposable
// public void resetPawnMoves(final Pawn pawn)
// {
- // removePawnFrom(pawn, getHexAt(pawn.getLastPosition()));
+ // removePawnFrom(pawn, getHexAt(pawn.getCenter()));
// AnimationSequence seq = pawn.getResetMovesAnimation();
// seq.addAnimation(RunnableAnimation.get(pawn, new Runnable() {
// @Override
// public void run() {
- // GridPoint2 coords = getHexAt(pawn.getLastPosition());
+ // GridPoint2 coords = getHexAt(pawn.getCenter());
// pushPawnAt(pawn, coords);
// }
// }));
// addPawnAnimation(pawn, seq);
// }
+ private GridPoint2 getHexAt(Vector2 v)
+ {
+ if (v == null) return null;
+ return getHexAt(null, v.x, v.y);
+ }
+
private GridPoint2 getHexAt(Vector3 v)
{
if (v == null) return null;