Browse Source

[fx] Handle looping to FX2DAnimation

Clément Espeute 2 months ago
parent
commit
fc3ada3a6a
1 changed files with 5 additions and 0 deletions
  1. 5 0
      hrt/prefab/fx/FX2D.hx

+ 5 - 0
hrt/prefab/fx/FX2D.hx

@@ -174,6 +174,11 @@ class FX2DAnimation extends h2d.Object {
 			setTime(curTime);
 			super.sync(ctx);
 			localTime += ctx.elapsedTime * playSpeed;
+
+			if (loop && localTime > duration) {
+				localTime = (localTime % duration);
+			}
+
 			if( duration > 0 && curTime < duration && localTime >= duration) {
 				localTime = duration;
 				if( onEnd != null )