Skip to content

Commit

Permalink
fix fps counting
Browse files Browse the repository at this point in the history
  • Loading branch information
crowplexus authored Sep 7, 2024
1 parent 6f0a6b1 commit a0d4984
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions source/debug/FPSCounter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,15 @@ class FPSCounter extends TextField
// Event Handlers
private override function __enterFrame(deltaTime:Float):Void
{
final now:Float = haxe.Timer.stamp() * 1000;
times.push(now);
while (times[0] < now - 1000) times.shift();
// prevents the overlay from updating every frame, why would you need to anyways @crowplexus
if (deltaTimeout < 1000) {
deltaTimeout += deltaTime;
return;
}

final now:Float = haxe.Timer.stamp() * 1000;
times.push(now);
while (times[0] < now - 1000) times.shift();

currentFPS = times.length < FlxG.updateFramerate ? times.length : FlxG.updateFramerate;
updateText();
deltaTimeout = 0.0;
Expand Down

0 comments on commit a0d4984

Please sign in to comment.