diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-02 13:28:51 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2014-11-02 13:28:51 +0100 |
commit | ed6e85c99d41d1069dbc52e9c32937706f1c505a (patch) | |
tree | 27e9f2f6541fae3b19a45b2533f9fe8f3e84592d /core | |
parent | 607fdc973096deb44498f35b35edb3670f134665 (diff) | |
download | RustAndDust-ed6e85c99d41d1069dbc52e9c32937706f1c505a.zip RustAndDust-ed6e85c99d41d1069dbc52e9c32937706f1c505a.tar.gz |
Image: add visible
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/tankontank/engine/gfx/Image.java | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/core/src/ch/asynk/tankontank/engine/gfx/Image.java b/core/src/ch/asynk/tankontank/engine/gfx/Image.java index 5797655..64063a6 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()))); } @@ -49,8 +54,16 @@ public class Image extends Sprite implements Drawable, Disposable } @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()); } } |