diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-11-23 15:54:52 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-11-23 15:54:52 +0100 |
commit | 83a2d2607d89d344c853eb0d81ca10b7d9f1dd7e (patch) | |
tree | c0c8f52bb5987373fe9502fd0efb53159e7e8f9e | |
parent | e2e3fb2311e1b1f2a7ccd057288aae635f9f6b9d (diff) | |
download | gdx-boardgame-83a2d2607d89d344c853eb0d81ca10b7d9f1dd7e.zip gdx-boardgame-83a2d2607d89d344c853eb0d81ca10b7d9f1dd7e.tar.gz |
FramedSprite : implement Positionable
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/FramedSprite.java | 33 |
1 files changed, 32 insertions, 1 deletions
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); |