Skip to content

Commit

Permalink
Merge pull request #15483 from crowplexus/patch-6
Browse files Browse the repository at this point in the history
Fix overlay updating every frame instead of every second
  • Loading branch information
ShadowMario committed Sep 15, 2024
2 parents 5841809 + a0d4984 commit c769a2a
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions source/debug/FPSCounter.hx
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@ class FPSCounter extends TextField
// Event Handlers
private override function __enterFrame(deltaTime:Float):Void
{
// prevents the overlay from updating every frame, why would you need to anyways
if (deltaTimeout > 1000) {
deltaTimeout = 0.0;
return;
}

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;
}

currentFPS = times.length < FlxG.updateFramerate ? times.length : FlxG.updateFramerate;
updateText();
deltaTimeout += deltaTime;
deltaTimeout = 0.0;
}

public dynamic function updateText():Void { // so people can override it in hscript
Expand Down

0 comments on commit c769a2a

Please sign in to comment.