From fd33d6367e23e7fb583dba78b9cde08dd2cb4b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 2 Oct 2014 23:42:03 +0200 Subject: StackedImages: is no longer a Moveable but a Drawable it only implements - setRotation(float r) - translate(float dx, float dy) - centerOn(float cx, float cy) --- .../asynk/tankontank/engine/gfx/StackedImages.java | 66 +++------------------- 1 file changed, 8 insertions(+), 58 deletions(-) diff --git a/core/src/ch/asynk/tankontank/engine/gfx/StackedImages.java b/core/src/ch/asynk/tankontank/engine/gfx/StackedImages.java index 48f7daa..4f72f76 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/StackedImages.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/StackedImages.java @@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.utils.Array; -public class StackedImages implements Moveable +public class StackedImages implements Drawable { private boolean enabled[]; private Array sprites; @@ -28,88 +28,39 @@ public class StackedImages implements Moveable enabled[i] = enable; } - public boolean isEnabled() - { - for (int i = 0; i < sprites.size; i++) - if (enabled[i]) return true; - return false; - } - public boolean isEnabled(int i) { return enabled[i]; } - @Override - public float getX() - { - return sprites.get(0).getX(); - } - - @Override - public float getY() - { - return sprites.get(0).getY(); - } - - @Override - public float getWidth() - { - return sprites.get(0).getWidth(); - } - - @Override - public float getHeight() - { - return sprites.get(0).getHeight(); - } - - @Override - public float getRotation() + public boolean isEnabled() { - return sprites.get(0).getRotation(); + for (int i = 0; i < sprites.size; i++) + if (enabled[i]) return true; + return false; } - @Override public void setRotation(float r) { for (int i = 0, n = sprites.size; i < n; i++) sprites.get(i).setRotation(r); } - @Override public void translate(float dx, float dy) { for (int i = 0, n = sprites.size; i < n; i++) sprites.get(i).translate(dx, dy); } - @Override public void centerOn(float cx, float cy) { - float x = (cx - (getWidth() / 2f)); - float y = (cy - (getHeight() / 2f)); - for (int i = 0, n = sprites.size; i < n; i++) - setPosition(x, y); - } - - @Override - public void setPosition(float x, float y) - { - for (int i = 0, n = sprites.size; i < n; i++) - sprites.get(i).setPosition(x, y); - } - - @Override - public void setPosition(float x, float y, float r) - { - for (int i = 0; i < sprites.size; i++) { + for (int i = 0, n = sprites.size; i < n; i++) { + float x = (cx - (sprites.get(i).getWidth() / 2f)); + float y = (cy - (sprites.get(i).getHeight() / 2f)); sprites.get(i).setPosition(x, y); - sprites.get(i).setRotation(r); } } - @Override public void draw(Batch batch) { for (int i = 0, n = sprites.size; i < n; i++) { @@ -118,7 +69,6 @@ public class StackedImages implements Moveable } } - @Override public void drawDebug(ShapeRenderer shapes) { Sprite sprite = sprites.get(0); -- cgit v1.1-2-g2b99