summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/ch/asynk/rustanddust')
-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