diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-23 18:41:43 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-02-23 18:41:43 +0100 |
commit | abb47a87f2f6b2af388c516094b8566a3740a214 (patch) | |
tree | aa0c94f1828365c0c4c6c3d0b366c44139e94aea /core | |
parent | 83b4c581ada9b67c0a878659581295377f29094c (diff) | |
download | RustAndDust-abb47a87f2f6b2af388c516094b8566a3740a214.zip RustAndDust-abb47a87f2f6b2af388c516094b8566a3740a214.tar.gz |
MenuCtrl: improve touch(float, float)
Diffstat (limited to 'core')
-rw-r--r-- | core/src/ch/asynk/rustanddust/menu/MenuCtrl.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java b/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java index 40a75c2..a28b2e7 100644 --- a/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java +++ b/core/src/ch/asynk/rustanddust/menu/MenuCtrl.java @@ -70,6 +70,8 @@ public class MenuCtrl implements Disposable, Drawable public boolean touch(float x, float y) { + MenuType next = MenuType.NONE; + if (okCancel.hit(x, y)) { if (okCancel.ok) game.playEnter(); @@ -77,11 +79,10 @@ public class MenuCtrl implements Disposable, Drawable game.playType(); visible = true; okCancel.visible = false; - panels[current.i].postAnswer(okCancel.ok); - return false; + return changePanel(panels[current.i].postAnswer(okCancel.ok)); } - MenuType next = panels[current.i].touch(x, y); + next = panels[current.i].touch(x, y); if (next == MenuType.BEGIN) return true; @@ -100,10 +101,18 @@ public class MenuCtrl implements Disposable, Drawable return false; } + return changePanel(next); + } + + private boolean changePanel(MenuType next) + { + if (next == MenuType.BEGIN) return true; + if (next != MenuType.NONE) { while(current != next) { current = next; next = panels[next.i].prepare(); + if (next == MenuType.BEGIN) return true; } } |