diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-06 11:14:15 +0100 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-11-06 11:14:15 +0100 | 
| commit | 24a9d3dc06095417510fce779fb141e0997f7739 (patch) | |
| tree | a4ea56397f3cac871d1ff90379df1e23dfd4b42f | |
| parent | 5a8b73c6b5337733450e611808f938e0cfb35296 (diff) | |
| download | RustAndDust-24a9d3dc06095417510fce779fb141e0997f7739.zip RustAndDust-24a9d3dc06095417510fce779fb141e0997f7739.tar.gz | |
UnitDock: smooth vertical adjustment
| -rw-r--r-- | core/src/ch/asynk/rustanddust/game/hud/UnitDock.java | 13 | 
1 files changed, 9 insertions, 4 deletions
| diff --git a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java index 10d604e..b3594dc 100644 --- a/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java +++ b/core/src/ch/asynk/rustanddust/game/hud/UnitDock.java @@ -22,6 +22,7 @@ public class UnitDock extends Bg implements Animation  {      private static final float SCALE = 0.4f;      private static final float STEP = 5f; +    private static final float BOUNCE_SPEED = 5;      private static final float SCISSORS_BOTTOM = 50f;      private final Ctrl ctrl; @@ -112,10 +113,6 @@ public class UnitDock extends Bg implements Animation      public void drag(int dx, int dy)      {          this.dy += dy; -        if ((rect.y + this.dy + rect.height) < y) -            this.dy = (y - rect.height - rect.y); -        else if (scaledRect.y > SCISSORS_BOTTOM) -            this.dy -= (scaledRect.y - SCISSORS_BOTTOM);          compute();      } @@ -217,6 +214,14 @@ 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(); +        } +          saved.set(batch.getTransformMatrix());          batch.setTransformMatrix(transform); | 
