From 83a2d2607d89d344c853eb0d81ca10b7d9f1dd7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 23 Nov 2018 15:54:52 +0100 Subject: FramedSprite : implement Positionable --- core/src/ch/asynk/gdx/boardgame/FramedSprite.java | 33 ++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/core/src/ch/asynk/gdx/boardgame/FramedSprite.java b/core/src/ch/asynk/gdx/boardgame/FramedSprite.java index 33a6eb2..b09a3af 100644 --- a/core/src/ch/asynk/gdx/boardgame/FramedSprite.java +++ b/core/src/ch/asynk/gdx/boardgame/FramedSprite.java @@ -4,7 +4,7 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.TextureRegion; -public class FramedSprite implements Drawable +public class FramedSprite implements Drawable, Positionable { private TextureRegion[][] frames; private TextureRegion frame; @@ -46,6 +46,37 @@ public class FramedSprite implements Drawable return frame; } + @Override public float getX() + { + return x; + } + + @Override public float getY() + { + return y; + } + + @Override public float getWidth() + { + return frame.getRegionWidth(); + } + + @Override public float getHeight() + { + return frame.getRegionHeight(); + } + + @Override public void translate(float dx, float dy) + { + setPosition(getX() + dx, getY() + dy); + } + + @Override public void setPosition(float x, float y) + { + this.x = x; + this.y = y; + } + @Override public void draw(Batch batch) { batch.draw(frame, x, y, 0, 0, frame.getRegionWidth(), frame.getRegionHeight(), 1f, 1f, a); -- cgit v1.1-2-g2b99