From 48959904e8d063e055971d33b2c205236ebbd3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 10 Dec 2015 09:01:25 +0100 Subject: Hud: add delay before closing engagement dialog after animations done --- core/src/ch/asynk/rustanddust/game/Hud.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/src/ch/asynk/rustanddust/game/Hud.java b/core/src/ch/asynk/rustanddust/game/Hud.java index 033baaf..522837e 100644 --- a/core/src/ch/asynk/rustanddust/game/Hud.java +++ b/core/src/ch/asynk/rustanddust/game/Hud.java @@ -28,6 +28,7 @@ public class Hud implements Disposable, Animation { public static final float OFFSET = 10f; public static final float NOTIFY_DURATION = 2f; + private static final float CLOSE_DELAY = 0.8f; private final RustAndDust game; private final Ctrl ctrl; @@ -37,6 +38,8 @@ public class Hud implements Disposable, Animation public PlayerInfo playerInfo; public ActionButtons actionButtons; + private float delay; + private boolean delayOn; private Msg msg; private StatisticsPanel stats; private EngagementPanel engagement; @@ -56,6 +59,7 @@ public class Hud implements Disposable, Animation { this.game = game; this.ctrl = game.ctrl; + this.delayOn = false; TextureAtlas hudAtlas = game.factory.hudAtlas; playerInfo = new PlayerInfo(ctrl, game.font, game.uiAtlas, hudAtlas); @@ -99,6 +103,12 @@ public class Hud implements Disposable, Animation @Override public boolean animate(float delta) { + if (delayOn) { + delay -= delta; + if (delay < 0f) { + delayOver(); + } + } msg.animate(delta); playerInfo.animate(delta); engagement.animate(delta); @@ -248,6 +258,13 @@ public class Hud implements Disposable, Animation public void notifyAnimationsEnd() { + delay = CLOSE_DELAY; + delayOn = true; + } + + private void delayOver() + { + delayOn = false; Widget dialog = dialogs.getFirst(); if (dialog == engagement) closeDialog(); -- cgit v1.1-2-g2b99