From c5f4b4b9c64a4054f77c558955fd20e9047e3556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 6 Nov 2015 17:00:34 +0100 Subject: UnitDock: avoid silly yoyo bouncing --- core/src/ch/asynk/rustanddust/game/hud/UnitDock.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java index b3594dc..d9acb8d 100644 --- a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java +++ b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java @@ -214,12 +214,15 @@ public class UnitDock extends Bg implements Animation { if (!visible) return; - if ((rect.y + this.dy + rect.height) < y) { - this.dy += BOUNCE_SPEED; - compute(); - } else if (scaledRect.y > SCISSORS_BOTTOM) { - this.dy -= BOUNCE_SPEED; - compute(); + float top = scaledRect.y + scaledRect.height; + if (top != y) { + if (top < y) { + this.dy += Math.min(BOUNCE_SPEED, (y - top)); + compute(); + } else if (scaledRect.y > SCISSORS_BOTTOM) { + this.dy -= Math.min(BOUNCE_SPEED, (scaledRect.y - SCISSORS_BOTTOM)); + compute(); + } } saved.set(batch.getTransformMatrix()); -- cgit v1.1-2-g2b99