Skip to content

Commit bfadb01

Browse files
committed
Update FPSCounter.hx
1 parent 0810322 commit bfadb01

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

source/debug/FPSCounter.hx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,19 @@ class FPSCounter extends TextField
5151
multiline = true;
5252
text = "FPS: ";
5353

54-
FlxG.signals.gameResized.add(rescale);
54+
FlxG.signals.gameResized.add(function(w, h)
55+
{
56+
setScale(Math.min(openfl.Lib.current.stage.stageWidth / FlxG.width, openfl.Lib.current.stage.stageHeight / FlxG.height));
57+
});
5558

5659
times = [];
5760
}
5861

59-
function rescale(width:Int, height:Int):Void {
60-
var scale:Float = height / 720;
61-
62-
this.scaleX = scale;
63-
this.scaleY = scale;
62+
public inline function setScale(?scale:Float)
63+
{
64+
if (scale == null)
65+
scale = Math.min(FlxG.stage.window.width / FlxG.width, FlxG.stage.window.height / FlxG.height);
66+
scaleX = scaleY = #if android (scale > 1 ? scale : 1) #else (scale < 1 ? scale : 1) #end;
6467
}
6568

6669
var timeColor:Float = 0.0;

0 commit comments

Comments
 (0)