From 342c6cf9f5681760d713e6a57a92b472f4761a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 2 Oct 2014 23:46:16 +0200 Subject: Pawn,HeadedPaw: use StackedImage.centerOn(float, float) not setPosition(...) --- core/src/ch/asynk/tankontank/engine/HeadedPawn.java | 6 +++--- core/src/ch/asynk/tankontank/engine/Pawn.java | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java index 427d61f..affe98b 100644 --- a/core/src/ch/asynk/tankontank/engine/HeadedPawn.java +++ b/core/src/ch/asynk/tankontank/engine/HeadedPawn.java @@ -45,9 +45,9 @@ public abstract class HeadedPawn extends Pawn public void setPosition(float x, float y, float z) { super.setPosition(x, y); - float cx = x + (getWidth() / 2f) - (head.getWidth() / 2f); - float cy = y + (getHeight() / 2f) - (head.getHeight() / 2f); - head.setPosition(cx, cy); + float cx = x + (getWidth() / 2f); + float cy = y + (getHeight() / 2f); + head.centerOn(cx, cy); head.setRotation(z); this.orientation = Board.Orientation.fromRotation(z); } diff --git a/core/src/ch/asynk/tankontank/engine/Pawn.java b/core/src/ch/asynk/tankontank/engine/Pawn.java index b669bb7..8c39310 100644 --- a/core/src/ch/asynk/tankontank/engine/Pawn.java +++ b/core/src/ch/asynk/tankontank/engine/Pawn.java @@ -118,14 +118,19 @@ public abstract class Pawn extends Image implements Disposable public void setPosition(float x, float y) { super.setPosition(x, y); - overlays.setPosition(x, y); + float cx = x + (getWidth() / 2f); + float cy = y + (getHeight() / 2f); + overlays.centerOn(cx, cy); } @Override public void setPosition(float x, float y, float z) { super.setPosition(x, y, z); - overlays.setPosition(x, y, z); + float cx = x + (getWidth() / 2f); + float cy = y + (getHeight() / 2f); + overlays.centerOn(cx, cy); + overlays.setRotation(z); } @Override -- cgit v1.1-2-g2b99