From ed6e85c99d41d1069dbc52e9c32937706f1c505a Mon Sep 17 00:00:00 2001 From: Jérémy Zurcher Date: Sun, 2 Nov 2014 13:28:51 +0100 Subject: Image: add visible --- core/src/ch/asynk/tankontank/engine/gfx/Image.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'core/src/ch/asynk') diff --git a/core/src/ch/asynk/tankontank/engine/gfx/Image.java b/core/src/ch/asynk/tankontank/engine/gfx/Image.java index 57976551..64063a64 100644 --- a/core/src/ch/asynk/tankontank/engine/gfx/Image.java +++ b/core/src/ch/asynk/tankontank/engine/gfx/Image.java @@ -3,11 +3,13 @@ package ch.asynk.tankontank.engine.gfx; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.TextureRegion; +import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.Sprite; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; public class Image extends Sprite implements Drawable, Disposable { + public boolean visible ; private Texture texture; protected Image() @@ -18,12 +20,14 @@ public class Image extends Sprite implements Drawable, Disposable { super(texture); this.texture = texture; + this.visible = true; } public Image(TextureRegion region) { super(region); this.texture = null; + this.visible = true; } @Override @@ -34,6 +38,7 @@ public class Image extends Sprite implements Drawable, Disposable public boolean contains(float x, float y) { + if (!visible) return false; return ((x >= getX()) && (y >= getY()) && (x <= (getX() + getWidth())) && (y <= (getY() + getHeight()))); } @@ -48,9 +53,17 @@ public class Image extends Sprite implements Drawable, Disposable setPosition((cx - (getWidth() / 2f)), (cy - (getHeight() / 2f))); } + @Override + public void draw(Batch batch) + { + if (!visible) return; + super.draw(batch); + } + @Override public void drawDebug(ShapeRenderer shapes) { + if (!visible) return; shapes.rect(getX(), getY(), (getWidth() / 2f), (getHeight() / 2f), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); } } -- cgit v1.2.3