From 85a9405f4b9b1f8e68636fbd5c1cbbdf34843d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 22 Oct 2014 14:31:57 +0200 Subject: Pawn: add setOnTile(Tile, Orientation) --- core/src/ch/asynk/tankontank/engine/Board.java | 3 +-- core/src/ch/asynk/tankontank/engine/Pawn.java | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/Board.java b/core/src/ch/asynk/tankontank/engine/Board.java index aa58bab..026dd71 100644 --- a/core/src/ch/asynk/tankontank/engine/Board.java +++ b/core/src/ch/asynk/tankontank/engine/Board.java @@ -522,8 +522,7 @@ public abstract class Board implements Disposable public Pawn setPawnAt(Pawn pawn, GridPoint2 coords, Orientation o) { - Vector2 pos = getPawnPosAt(pawn, coords, null); - pawn.setPosition(pos.x, pos.y, o.r()); + pawn.setOnTile(getTile(coords.x, coords.y), o); pushPawnAt(pawn, coords); return pawn; } diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index f1626cc..35973fb 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -142,6 +142,13 @@ public abstract class Pawn implements Moveable, Disposable return pos; } + public void setOnTile(Tile tile, Orientation o) + { + float x = (tile.getX() - (image.getWidth() / 2f)); + float y = (tile.getY() - (image.getHeight() / 2f)); + setPosition(x, y, o.r()); + } + @Override public float getX() { -- cgit v1.1-2-g2b99