summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-11-06 17:00:34 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-11-06 17:00:34 +0100
commitc5f4b4b9c64a4054f77c558955fd20e9047e3556 (patch)
treea257d1cd425d21dafbbbba763fcdb422d1cc2e29
parentb9910179c1766f19cc16f259c765a3232b27c3b7 (diff)
downloadRustAndDust-c5f4b4b9c64a4054f77c558955fd20e9047e3556.zip
RustAndDust-c5f4b4b9c64a4054f77c558955fd20e9047e3556.tar.gz
UnitDock: avoid silly yoyo bouncing
-rw-r--r--core/src/ch/asynk/rustanddust/game/hud/UnitDock.java15
1 files 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());