summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2015-12-29 07:54:29 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2015-12-29 07:54:29 +0100
commitbc6ada37ab01906406f28efb2a28007d9c345666 (patch)
tree27454edc75a83ed1b3b4aa0d833ccca672b1d88f
parentb49dd88171a0f17b683b10bfc8f86c199ef21c57 (diff)
downloadRustAndDust-bc6ada37ab01906406f28efb2a28007d9c345666.zip
RustAndDust-bc6ada37ab01906406f28efb2a28007d9c345666.tar.gz
MoveToAnimation: gently set the turret rotation to 0
-rw-r--r--core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java b/core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java
index f6380bc..1ae3f00 100644
--- a/core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java
+++ b/core/src/ch/asynk/rustanddust/engine/gfx/animations/MoveToAnimation.java
@@ -23,6 +23,8 @@ public class MoveToAnimation extends TimedAnimation
private float toY;
private float toR;
private float rDelta;
+ private boolean aimed;
+ private float aimDelta;
private boolean notified;
private MoveToAnimationCb cb;
@@ -86,6 +88,9 @@ public class MoveToAnimation extends TimedAnimation
else
rDelta = (toR + 360 - fromR);
}
+
+ aimDelta = moveable.getTurretRotation();
+ aimed = (Math.abs(aimDelta) < 1f);
}
@Override
@@ -106,10 +111,14 @@ public class MoveToAnimation extends TimedAnimation
cb.moveToAnimationEnter(moveable, (toX + dw), (toY + dh), toR);
notified = true;
}
- if (percent == 1f)
+ if (percent == 1f) {
moveable.setPosition(toX, toY, (int) toR);
- else
+ if (!aimed) moveable.setTurretRotation(0f);
+ }
+ else {
moveable.setPosition(fromX + ((toX - fromX) * percent), fromY + ((toY - fromY) * percent), (fromR + (rDelta * percent)));
+ if (!aimed) moveable.setTurretRotation((aimDelta * (1f - percent)));
+ }
}
@Override