diff options
Diffstat (limited to 'core/src/ch/asynk/gdx/boardgame/ui')
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/ui/Assembly.java | 14 | ||||
-rw-r--r-- | core/src/ch/asynk/gdx/boardgame/ui/Element.java | 6 |
2 files changed, 19 insertions, 1 deletions
diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java b/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java index 6754518..866c3dd 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Assembly.java @@ -41,15 +41,27 @@ public abstract class Assembly extends Element @Override public boolean touch(float x, float y) { - for (Element e : children) + for (Element e : children) { if (e.touch(x, y)) { touched = e; return true; } + + } touched = null; return false; } + @Override public boolean drag(float x, float y, int dx, int dy) + { + if (touched != null) { + if (touched.drag(x, y, dx, dy)) + return true; + touched = null; + } + return false; + } + @Override public void draw(Batch batch) { if (tainted) computeGeometry(); diff --git a/core/src/ch/asynk/gdx/boardgame/ui/Element.java b/core/src/ch/asynk/gdx/boardgame/ui/Element.java index 3368f3c..dec0cc7 100644 --- a/core/src/ch/asynk/gdx/boardgame/ui/Element.java +++ b/core/src/ch/asynk/gdx/boardgame/ui/Element.java @@ -83,6 +83,12 @@ public abstract class Element implements Drawable, Paddable, Positionable, Touch return rect.contains(x, y); } + @Override public boolean drag(float x, float y, int dx, int dy) + { + if (blocked || !visible) return false; + return rect.contains(x, y); + } + public void taint() { this.tainted = true; |