File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff 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 ;
You can’t perform that action at this time.
0 commit comments