summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/gdx
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2018-11-23 15:54:38 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2018-11-23 15:54:38 +0100
commite2e3fb2311e1b1f2a7ccd057288aae635f9f6b9d (patch)
tree685138314cc76dcf3ad722392642fea4cd271177 /core/src/ch/asynk/gdx
parente62c838c3da5cd091c86844d3e8649ba4c3fe5dd (diff)
downloadgdx-boardgame-e2e3fb2311e1b1f2a7ccd057288aae635f9f6b9d.zip
gdx-boardgame-e2e3fb2311e1b1f2a7ccd057288aae635f9f6b9d.tar.gz
Positionable : give default centerOn() implementation
Diffstat (limited to 'core/src/ch/asynk/gdx')
-rw-r--r--core/src/ch/asynk/gdx/boardgame/Piece.java5
-rw-r--r--core/src/ch/asynk/gdx/boardgame/Positionable.java6
2 files changed, 5 insertions, 6 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/Piece.java b/core/src/ch/asynk/gdx/boardgame/Piece.java
index 6b7f2b4..a2017b0 100644
--- a/core/src/ch/asynk/gdx/boardgame/Piece.java
+++ b/core/src/ch/asynk/gdx/boardgame/Piece.java
@@ -27,11 +27,6 @@ public class Piece extends Sprite implements Drawable, Positionable, Rotable, Sc
return getScaleX();
}
- @Override public void centerOn(float cx, float cy)
- {
- setPosition((cx - (getWidth() / 2f)), (cy - (getHeight() / 2f)));
- }
-
public void getPosOn(Tile tile, Orientation orientation, Vector3 v)
{
v.set((tile.x - (getWidth() / 2f)), (tile.y- (getHeight() / 2f)), orientation.r());
diff --git a/core/src/ch/asynk/gdx/boardgame/Positionable.java b/core/src/ch/asynk/gdx/boardgame/Positionable.java
index 30128ac..53d92f8 100644
--- a/core/src/ch/asynk/gdx/boardgame/Positionable.java
+++ b/core/src/ch/asynk/gdx/boardgame/Positionable.java
@@ -6,7 +6,11 @@ public interface Positionable
public float getY();
public float getWidth();
public float getHeight();
- public void centerOn(float cx, float cy);
public void translate(float dx, float dy);
public void setPosition(float x, float y);
+
+ default public void centerOn(float cx, float cy)
+ {
+ setPosition((cx - (getWidth() / 2f)), (cy - (getHeight() / 2f)));
+ }
}