Parcourir la source

removed hxd.Math.scaleTime (can be misleading) + use wantedFPS for lerpTime

Nicolas Cannasse il y a 4 ans
Parent
commit
2a7038118c
2 fichiers modifiés avec 6 ajouts et 7 suppressions
  1. 4 5
      hxd/Math.hx
  2. 2 2
      samples/Network.hx

+ 4 - 5
hxd/Math.hx

@@ -64,10 +64,6 @@ class Math {
 		return std.Math.pow(v,p);
 		return std.Math.pow(v,p);
 	}
 	}
 
 
-	public static inline function scaleTime( v : Float, et : Float ) {
-		return std.Math.pow(v,et * hxd.Timer.wantedFPS);
-	}
-
 	public static inline function cos( f : Float ) {
 	public static inline function cos( f : Float ) {
 		return std.Math.cos(f);
 		return std.Math.cos(f);
 	}
 	}
@@ -139,8 +135,11 @@ class Math {
 		return a + k * (b - a);
 		return a + k * (b - a);
 	}
 	}
 
 
+	/**
+		Same as lerp but is scaled based on current FPS, using current elapsed time in seconds.
+	**/
 	public inline static function lerpTime(a:Float, b:Float, k:Float, dt:Float) {
 	public inline static function lerpTime(a:Float, b:Float, k:Float, dt:Float) {
-		return lerp(a, b, 1 - Math.pow(1 - k,dt*60));
+		return lerp(a, b, 1 - Math.pow(1 - k, dt * hxd.Timer.wantedFPS));
 	}
 	}
 
 
 	public inline static function bitCount(v:Int) {
 	public inline static function bitCount(v:Int) {

+ 2 - 2
samples/Network.hx

@@ -56,8 +56,8 @@ class Cursor implements hxbit.NetworkSerializable {
 	@:rpc function blink( s : Float ) {
 	@:rpc function blink( s : Float ) {
 		bmp.scale(s);
 		bmp.scale(s);
 		net.event.waitUntil(function(dt) {
 		net.event.waitUntil(function(dt) {
-			bmp.scaleX *= hxd.Math.scaleTime(0.9, dt);
-			bmp.scaleY *= hxd.Math.scaleTime(0.9, dt);
+			bmp.scaleX *= Math.pow(0.9, dt * 60);
+			bmp.scaleY *= Math.pow(0.9, dt * 60);
 			if( bmp.scaleX < 1 ) {
 			if( bmp.scaleX < 1 ) {
 				bmp.scaleX = bmp.scaleY = 1;
 				bmp.scaleX = bmp.scaleY = 1;
 				return true;
 				return true;