From bc6ada37ab01906406f28efb2a28007d9c345666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Tue, 29 Dec 2015 07:54:29 +0100 Subject: MoveToAnimation: gently set the turret rotation to 0 --- .../rustanddust/engine/gfx/animations/MoveToAnimation.java | 13 +++++++++++-- 1 file 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 -- cgit v1.1-2-g2b99