-
-
Notifications
You must be signed in to change notification settings - Fork 320
Expand file tree
/
Copy pathFunkinGame.hx
More file actions
39 lines (32 loc) · 1.16 KB
/
FunkinGame.hx
File metadata and controls
39 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package funkin.backend.system;
import flixel.FlxGame;
import flixel.FlxG;
import flixel.FlxState;
import openfl.events.KeyboardEvent;
class FunkinGame extends FlxGame {
var skipNextTickUpdate:Bool = false;
#if desktop
var fullscreenListener:KeyboardEvent->Void;
public function new(gameWidth:Int, gameHeight:Int, entryState:Class<FlxState>, updateFramerate:Int = 60, drawFramerate:Int = 60, skipSplash:Bool = false, startFullscreen:Bool = false) {
super(gameWidth, gameHeight, entryState, updateFramerate, drawFramerate, skipSplash, startFullscreen);
fullscreenListener = function(e:KeyboardEvent) {
if (e.keyCode == 122) {
FlxG.fullscreen = !FlxG.fullscreen;
}
};
FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, fullscreenListener);
}
#end
public override function switchState() {
super.switchState();
// draw once to put all images in gpu then put the last update time to now to prevent lag spikes or whatever
draw();
_total = ticks = getTicks();
skipNextTickUpdate = true;
}
public override function onEnterFrame(t) {
if (skipNextTickUpdate != (skipNextTickUpdate = false))
_total = ticks = getTicks();
super.onEnterFrame(t);
}
}