Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix overlay updating every frame instead of every second #15483

Merged
merged 2 commits into from
Sep 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading