diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2018-10-18 16:49:56 +0200 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2018-10-18 16:49:56 +0200 |
commit | 132094f02ec5134c1b47553c1655d880f4127782 (patch) | |
tree | b534714d7e2f903a8cc822035542b6992f6823ec /core/src/ch/asynk/gdx | |
parent | 3be9db7d4d603791727b2cb3bcec7ae38d3cda50 (diff) | |
download | gdx-boardgame-132094f02ec5134c1b47553c1655d880f4127782.zip gdx-boardgame-132094f02ec5134c1b47553c1655d880f4127782.tar.gz |
Overlays : add attribute isEnabled
Diffstat (limited to 'core/src/ch/asynk/gdx')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/Overlays.java | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/Overlays.java b/core/src/ch/asynk/gdx/boardgame/Overlays.java index fb77d55..b1cdba3 100644 --- a/core/src/ch/asynk/gdx/boardgame/Overlays.java +++ b/core/src/ch/asynk/gdx/boardgame/Overlays.java @@ -13,6 +13,7 @@ import ch.asynk.gdx.boardgame.Scalable; public class Overlays implements Drawable, Positionable, Rotable, Scalable { + private boolean isEnabled; private boolean enabled[]; private Array<Sprite> sprites; @@ -20,17 +21,26 @@ public class Overlays implements Drawable, Positionable, Rotable, Scalable { this.sprites = atlas.createSprites(); this.enabled = new boolean[sprites.size]; + this.isEnabled = false; } public void disableAll() { for (int i = 0; i < sprites.size; i++) enabled[i] = false; + isEnabled = false; } public void enable(int i, boolean enable) { enabled[i] = enable; + for (int j = 0; j < sprites.size; j++) { + if (enabled[j]) { + isEnabled = true; + return; + } + } + isEnabled = false; } public boolean isEnabled(int i) @@ -40,12 +50,7 @@ public class Overlays implements Drawable, Positionable, Rotable, Scalable public boolean isEnabled() { - for (int i = 0; i < sprites.size; i++) { - if (enabled[i]) { - return true; - } - } - return false; + return isEnabled; } @Override public float getX() { return sprites.get(0).getX(); } @@ -109,6 +114,7 @@ public class Overlays implements Drawable, Positionable, Rotable, Scalable @Override public void draw(Batch batch) { + if (!isEnabled) return; for (int i = 0, n = sprites.size; i < n; i++) { if (enabled[i]) { sprites.get(i).draw(batch); |