From 132094f02ec5134c1b47553c1655d880f4127782 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 18 Oct 2018 16:49:56 +0200 Subject: Overlays : add attribute isEnabled --- core/src/ch/asynk/gdx/boardgame/Overlays.java | 18 ++++++++++++------ 1 file 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 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); -- cgit v1.1-2-g2b99