/
FlxGame.hx
900 lines (756 loc) · 19.6 KB
/
FlxGame.hx
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
package flixel;
import flash.Lib;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.FocusEvent;
import flixel.effects.postprocess.PostProcess;
import flixel.graphics.tile.FlxTilesheet;
import flixel.math.FlxRandom;
import flixel.system.FlxSplash;
import flixel.system.replay.FlxReplay;
import flixel.util.FlxArrayUtil;
import openfl.Assets;
import openfl.filters.BitmapFilter;
#if FLX_POST_PROCESS
import openfl.display.OpenGLView;
#end
#if FLX_DEBUG
import flixel.system.debug.FlxDebugger;
#end
#if FLX_SOUND_TRAY
import flixel.system.ui.FlxSoundTray;
#end
#if FLX_FOCUS_LOST_SCREEN
import flixel.system.ui.FlxFocusLostScreen;
#end
/**
* FlxGame is the heart of all flixel games, and contains a bunch of basic game loops and things.
* It is a long and sloppy file that you shouldn't have to worry about too much!
* It is basically only used to create your game object in the first place,
* after that FlxG and FlxState have all the useful stuff you actually need.
*/
@:allow(flixel)
class FlxGame extends Sprite
{
/**
* Framerate to use on focus lost. Default = 10.
*/
public var focusLostFramerate:Int = 10;
#if FLX_RECORD
/**
* Flag for whether a replay is currently playing.
*/
public var replaying(default, null):Bool = false;
/**
* Flag for whether a new recording is being made.
*/
public var recording(default, null):Bool = false;
#end
#if FLX_SOUND_TRAY
/**
* The sound tray display container (see createSoundTray()).
*/
public var soundTray(default, null):FlxSoundTray;
#end
#if FLX_DEBUG
/**
* The debugger overlay object.
*/
public var debugger(default, null):FlxDebugger;
#end
/**
* Time in milliseconds that has passed (amount of "ticks" passed) since the game has started.
*/
public var ticks(default, null):Int = 0;
/**
* Enables or disables the filters set via setFilters()
*/
public var filtersEnabled:Bool = true;
/**
* A flag for triggering the onGameStart "event".
*/
@:allow(flixel.system.FlxSplash)
private var _gameJustStarted:Bool = false;
/**
* Class type of the initial/first game state for the game, usually MenuState or something like that.
*/
private var _initialState:Class<FlxState>;
/**
* Current game state.
*/
private var _state:FlxState;
/**
* Total number of milliseconds elapsed since game start.
*/
private var _total:Int = 0;
/**
* Time stamp of game startup.
* Need to add this var for js target where Lib.getTimer() returns time stamp of current date,
* not the time passed since app start.
*/
private var _startTime:Int = 0;
/**
* Total number of milliseconds elapsed since last update loop.
* Counts down as we step through the game loop.
*/
private var _accumulator:Float;
/**
* Milliseconds of time since last step.
*/
private var _elapsedMS:Float;
/**
* Milliseconds of time per step of the game loop. e.g. 60 fps = 16ms.
*/
private var _stepMS:Float;
/**
* Optimization so we don't have to divide step by 1000 to get its value in seconds every frame.
*/
private var _stepSeconds:Float;
/**
* Max allowable accumulation (see _accumulator).
* Should always (and automatically) be set to roughly 2x the stage framerate.
*/
private var _maxAccumulation:Float;
/**
* Whether the game lost focus.
*/
private var _lostFocus:Bool = false;
/**
* The filters array to be applied to the game.
*/
private var _filters:Array<BitmapFilter>;
#if (desktop && lime_legacy)
/**
* Ugly workaround to ensure consistent behaviour between flash and cpp
* (the focus event should not fire when the game starts up!)
*/
private var _onFocusFiredOnce:Bool = false;
#end
#if FLX_FOCUS_LOST_SCREEN
/**
* The "focus lost" screen (see createFocusScreen()).
*/
private var _focusLostScreen:FlxFocusLostScreen;
#end
/**
* Mouse cursor.
*/
@:allow(flixel.FlxG)
@:allow(flixel.system.frontEnds.CameraFrontEnd)
private var _inputContainer:Sprite;
#if FLX_SOUND_TRAY
/**
* Change this after calling super() in the FlxGame constructor to use a customized sound tray based on FlxSoundTray.
*/
private var _customSoundTray:Class<FlxSoundTray> = FlxSoundTray;
#end
#if FLX_FOCUS_LOST_SCREEN
/**
* Change this after calling super() in the FlxGame constructor to use a customized screen which will be show when the application lost focus.
*/
private var _customFocusLostScreen:Class<FlxFocusLostScreen> = FlxFocusLostScreen;
#end
/**
* Whether the splash screen should be skipped.
*/
private var _skipSplash:Bool = false;
#if desktop
/**
* Should we start Fullscreen or not? This is useful if you want to load Fullscreen settings from a FlxSave and set it when the game starts, instead of having it hard-set in your project XML.
*/
private var _startFullscreen:Bool = false;
#end
/**
* If a state change was requested, the new state object is stored here until we switch to it.
*/
private var _requestedState:FlxState;
/**
* A flag for keeping track of whether a game reset was requested or not.
*/
private var _resetGame:Bool = false;
#if FLX_RECORD
/**
* Container for a game replay object.
*/
private var _replay:FlxReplay;
/**
* Flag for whether a playback of a recording was requested.
*/
private var _replayRequested:Bool = false;
/**
* Flag for whether a new recording was requested.
*/
private var _recordingRequested:Bool = false;
#end
#if FLX_POST_PROCESS
/**
* Sprite for postprocessing effects
*/
private var postProcessLayer:Sprite = new Sprite();
/**
* Post process effects active on the postProcessLayer
*/
private var postProcesses:Array<PostProcess> = [];
#end
/**
* Instantiate a new game object.
*
* @param GameWidth The width of your game in game pixels, not necessarily final display pixels (see `Zoom`).
* If equal to 0, the window width specified in the `Project.xml` is used.
* @param GameHeight The height of your game in game pixels, not necessarily final display pixels (see `Zoom`).
* If equal to 0, the window height specified in the `Project.xml` is used.
* @param InitialState The class name of the state you want to create and switch to first (e.g. `MenuState`).
* @param Zoom The default level of zoom for the game's cameras (e.g. 2 = all pixels are now drawn at 2x).
* @param UpdateFramerate How frequently the game should update (default is 60 times per second).
* @param DrawFramerate Sets the actual display / draw framerate for the game (default is 60 times per second).
* @param SkipSplash Whether you want to skip the flixel splash screen with `FLX_NO_DEBUG`.
* @param StartFullscreen Whether to start the game in fullscreen mode (desktop targets only).
*/
public function new(GameWidth:Int = 0, GameHeight:Int = 0, ?InitialState:Class<FlxState>, Zoom:Float = 1,
UpdateFramerate:Int = 60, DrawFramerate:Int = 60, SkipSplash:Bool = false, StartFullscreen:Bool = false)
{
super();
#if desktop
_startFullscreen = StartFullscreen;
#end
// Super high priority init stuff
_inputContainer = new Sprite();
if (GameWidth == 0)
GameWidth = FlxG.stage.stageWidth;
if (GameHeight == 0)
GameHeight = FlxG.stage.stageHeight;
// Basic display and update setup stuff
FlxG.init(this, GameWidth, GameHeight, Zoom);
FlxG.updateFramerate = UpdateFramerate;
FlxG.drawFramerate = DrawFramerate;
_accumulator = _stepMS;
_skipSplash = SkipSplash;
#if FLX_RECORD
_replay = new FlxReplay();
#end
// Then get ready to create the game object for real
_initialState = (InitialState == null) ? FlxState : InitialState;
addEventListener(Event.ADDED_TO_STAGE, create);
}
/**
* Sets the filter array to be applied to the game.
*/
public function setFilters(filters:Array<BitmapFilter>):Void
{
_filters = filters;
}
/**
* Used to instantiate the guts of the flixel game object once we have a valid reference to the root.
*/
private function create(_):Void
{
if (stage == null)
{
return;
}
removeEventListener(Event.ADDED_TO_STAGE, create);
_total = getTimer();
_startTime = _total;
#if desktop
FlxG.fullscreen = _startFullscreen;
#end
// Set up the view window and double buffering
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.frameRate = FlxG.drawFramerate;
addChild(_inputContainer);
#if FLX_POST_PROCESS
if (OpenGLView.isSupported)
addChild(postProcessLayer);
#end
// Creating the debugger overlay
#if FLX_DEBUG
debugger = new FlxDebugger(FlxG.stage.stageWidth, FlxG.stage.stageHeight);
addChild(debugger);
#end
// No need for overlays on mobile.
#if !mobile
// Volume display tab
#if FLX_SOUND_TRAY
soundTray = Type.createInstance(_customSoundTray, []);
addChild(soundTray);
#end
#if FLX_FOCUS_LOST_SCREEN
_focusLostScreen = Type.createInstance(_customFocusLostScreen, []);
addChild(_focusLostScreen);
#end
#end
// Focus gained/lost monitoring
#if desktop
stage.addEventListener(FocusEvent.FOCUS_OUT, onFocusLost);
stage.addEventListener(FocusEvent.FOCUS_IN, onFocus);
#else
stage.addEventListener(Event.DEACTIVATE, onFocusLost);
stage.addEventListener(Event.ACTIVATE, onFocus);
#end
// Instantiate the initial state
resetGame();
switchState();
if (FlxG.updateFramerate < FlxG.drawFramerate)
{
FlxG.log.warn("FlxG.updateFramerate: The update framerate shouldn't be smaller than the draw framerate, since it can slow down your game.");
}
// Finally, set up an event for the actual game loop stuff.
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
// We need to listen for resize event which means new context
// it means that we need to recreate bitmapdatas of dumped tilesheets
stage.addEventListener(Event.RESIZE, onResize);
// make sure the cursor etc are properly scaled from the start
resizeGame(FlxG.stage.stageWidth, FlxG.stage.stageHeight);
Assets.addEventListener(Event.CHANGE, FlxG.bitmap.onAssetsReload);
}
private function onFocus(_):Void
{
#if flash
if (!_lostFocus)
{
return; // Don't run this function twice (bug in standalone flash player)
}
#end
#if (desktop && lime_legacy)
// make sure the on focus event doesn't fire on startup
if (!_onFocusFiredOnce)
{
_onFocusFiredOnce = true;
return;
}
#end
#if mobile
// just check if device orientation has been changed
onResize(_);
#end
_lostFocus = false;
FlxG.signals.focusGained.dispatch();
_state.onFocus();
if (!FlxG.autoPause)
{
return;
}
#if FLX_FOCUS_LOST_SCREEN
if (_focusLostScreen != null)
{
_focusLostScreen.visible = false;
}
#end
#if FLX_DEBUG
debugger.stats.onFocus();
#end
stage.frameRate = FlxG.drawFramerate;
#if FLX_SOUND_SYSTEM
FlxG.sound.onFocus();
#end
FlxG.inputs.onFocus();
}
private function onFocusLost(_):Void
{
#if flash
if (_lostFocus)
{
return; // Don't run this function twice (bug in standalone flash player)
}
#end
_lostFocus = true;
FlxG.signals.focusLost.dispatch();
_state.onFocusLost();
if (!FlxG.autoPause)
{
return;
}
#if FLX_FOCUS_LOST_SCREEN
if (_focusLostScreen != null)
{
_focusLostScreen.visible = true;
}
#end
#if FLX_DEBUG
debugger.stats.onFocusLost();
#end
stage.frameRate = focusLostFramerate;
#if FLX_SOUND_SYSTEM
FlxG.sound.onFocusLost();
#end
FlxG.inputs.onFocusLost();
}
@:allow(flixel.FlxG)
private function onResize(_):Void
{
var width:Int = FlxG.stage.stageWidth;
var height:Int = FlxG.stage.stageHeight;
#if !flash
if (FlxG.renderTile)
{
FlxG.bitmap.onContext();
}
#end
resizeGame(width, height);
}
private function resizeGame(width:Int, height:Int):Void
{
FlxG.resizeGame(width, height);
_state.onResize(width, height);
FlxG.signals.gameResized.dispatch(width, height);
FlxG.cameras.resize();
#if FLX_DEBUG
debugger.onResize(width, height);
#end
#if FLX_FOCUS_LOST_SCREEN
if (_focusLostScreen != null)
{
_focusLostScreen.draw();
}
#end
#if FLX_SOUND_TRAY
if (soundTray != null)
{
soundTray.screenCenter();
}
#end
#if FLX_POST_PROCESS
for (postProcess in postProcesses)
{
postProcess.rebuild();
}
#end
}
/**
* Handles the onEnterFrame call and figures out how many updates and draw calls to do.
*/
private function onEnterFrame(_):Void
{
ticks = getTimer() - _startTime;
_elapsedMS = ticks - _total;
_total = ticks;
#if FLX_SOUND_TRAY
if (soundTray != null && soundTray.active)
{
soundTray.update(_elapsedMS);
}
#end
if (!_lostFocus || !FlxG.autoPause)
{
if (FlxG.vcr.paused)
{
if (FlxG.vcr.stepRequested)
{
FlxG.vcr.stepRequested = false;
}
else if (_state == _requestedState) // don't pause a state switch request
{
#if FLX_DEBUG
debugger.update();
#end
return;
}
}
if (FlxG.fixedTimestep)
{
_accumulator += _elapsedMS;
_accumulator = (_accumulator > _maxAccumulation) ? _maxAccumulation : _accumulator;
while (_accumulator >= _stepMS)
{
step();
_accumulator -= _stepMS;
}
}
else
{
step();
}
#if FLX_DEBUG
FlxBasic.visibleCount = 0;
#end
draw();
#if FLX_DEBUG
debugger.stats.visibleObjects(FlxBasic.visibleCount);
debugger.update();
#end
}
}
/**
* Internal method to create a new instance of iState and reset the game.
* This gets called when the game is created, as well as when a new state is requested.
*/
private inline function resetGame():Void
{
FlxG.signals.preGameReset.dispatch();
#if FLX_DEBUG
_skipSplash = true;
#end
if (_skipSplash || FlxSplash.nextState != null) // already played
{
_requestedState = cast Type.createInstance(_initialState, []);
if (FlxSplash.nextState == null)
{
_gameJustStarted = true;
}
}
else
{
FlxSplash.nextState = _initialState;
_requestedState = new FlxSplash();
_skipSplash = true; // only play it once
}
#if FLX_DEBUG
if (Std.is(_requestedState, FlxSubState))
{
throw "You can't set FlxSubState class instance as the state for you game";
}
#end
FlxG.reset();
FlxG.signals.postGameReset.dispatch();
}
/**
* If there is a state change requested during the update loop,
* this function handles actual destroying the old state and related processes,
* and calls creates on the new state and plugs it into the game object.
*/
private function switchState():Void
{
// Basic reset stuff
FlxG.bitmap.clearCache();
FlxG.cameras.reset();
FlxG.inputs.onStateSwitch();
#if FLX_SOUND_SYSTEM
FlxG.sound.destroy();
#end
FlxG.signals.stateSwitched.dispatch();
#if FLX_RECORD
FlxRandom.updateStateSeed();
#end
// Destroy the old state (if there is an old state)
if (_state != null)
{
_state.destroy();
}
// Finally assign and create the new state
_state = _requestedState;
FlxG.signals.preStateCreate.dispatch(_state);
_state.create();
if (_gameJustStarted)
{
gameStart();
}
#if FLX_DEBUG
debugger.console.registerObject("state", _state);
#end
}
private function gameStart():Void
{
FlxG.signals.gameStarted.dispatch();
_gameJustStarted = false;
}
/**
* This is the main game update logic section.
* The onEnterFrame() handler is in charge of calling this
* the appropriate number of times each frame.
* This block handles state changes, replays, all that good stuff.
*/
private function step():Void
{
// Handle game reset request
if (_resetGame)
{
resetGame();
_resetGame = false;
}
handleReplayRequests();
#if FLX_DEBUG
// Finally actually step through the game physics
FlxBasic.activeCount = 0;
#end
update();
#if FLX_DEBUG
debugger.stats.activeObjects(FlxBasic.activeCount);
#end
}
private function handleReplayRequests():Void
{
#if FLX_RECORD
// Handle replay-related requests
if (_recordingRequested)
{
_recordingRequested = false;
_replay.create(FlxRandom.getRecordingSeed());
recording = true;
#if FLX_DEBUG
debugger.vcr.recording();
FlxG.log.notice("Starting new flixel gameplay record.");
#end
}
else if (_replayRequested)
{
_replayRequested = false;
_replay.rewind();
FlxG.random.initialSeed = _replay.seed;
#if FLX_DEBUG
debugger.vcr.playingReplay();
#end
replaying = true;
}
#end
}
/**
* This function is called by step() and updates the actual game state.
* May be called multiple times per "frame" or draw call.
*/
private function update():Void
{
if (!_state.active || !_state.exists)
{
return;
}
if (_state != _requestedState)
{
switchState();
}
#if FLX_DEBUG
if (FlxG.debugger.visible)
{
ticks = getTimer(); // Lib.getTimer() is expensive, only do it if necessary
}
#end
updateElapsed();
FlxG.signals.preUpdate.dispatch();
updateInput();
#if FLX_POST_PROCESS
if (postProcesses[0] != null)
{
postProcesses[0].update(FlxG.elapsed);
}
#end
#if FLX_SOUND_SYSTEM
FlxG.sound.update(FlxG.elapsed);
#end
FlxG.plugins.update(FlxG.elapsed);
_state.tryUpdate(FlxG.elapsed);
FlxG.cameras.update(FlxG.elapsed);
FlxG.signals.postUpdate.dispatch();
#if FLX_DEBUG
debugger.stats.flixelUpdate(getTimer() - ticks);
#end
#if FLX_POINTER_INPUT
FlxArrayUtil.clearArray(FlxG.swipes);
#end
filters = filtersEnabled ? _filters : null;
}
private function updateElapsed():Void
{
if (FlxG.fixedTimestep)
{
FlxG.elapsed = FlxG.timeScale * _stepSeconds; // fixed timestep
}
else
{
FlxG.elapsed = FlxG.timeScale * (_elapsedMS / 1000); // variable timestep
var max = FlxG.maxElapsed * FlxG.timeScale;
if (FlxG.elapsed > max)
FlxG.elapsed = max;
}
}
private function updateInput():Void
{
#if FLX_RECORD
if (replaying)
{
_replay.playNextFrame();
if (FlxG.vcr.timeout > 0)
{
FlxG.vcr.timeout -= _stepMS;
if (FlxG.vcr.timeout <= 0)
{
if (FlxG.vcr.replayCallback != null)
{
FlxG.vcr.replayCallback();
FlxG.vcr.replayCallback = null;
}
else
{
FlxG.vcr.stopReplay();
}
}
}
if (replaying && _replay.finished)
{
FlxG.vcr.stopReplay();
if (FlxG.vcr.replayCallback != null)
{
FlxG.vcr.replayCallback();
FlxG.vcr.replayCallback = null;
}
}
#if FLX_DEBUG
debugger.vcr.updateRuntime(_stepMS);
#end
}
else
{
FlxG.inputs.update();
}
#else
FlxG.inputs.update();
#end
#if FLX_RECORD
if (recording)
{
_replay.recordFrame();
#if FLX_DEBUG
debugger.vcr.updateRuntime(_stepMS);
#end
}
#end
}
/**
* Goes through the game state and draws all the game objects and special effects.
*/
private function draw():Void
{
if (!_state.visible || !_state.exists)
{
return;
}
#if FLX_DEBUG
if (FlxG.debugger.visible)
{
// getTimer() is expensive, only do it if necessary
ticks = getTimer();
}
#end
FlxG.signals.preDraw.dispatch();
if (FlxG.renderTile)
{
FlxTilesheet._DRAWCALLS = 0;
}
#if FLX_POST_PROCESS
if (postProcesses[0] != null)
{
postProcesses[0].capture();
}
#end
FlxG.cameras.lock();
FlxG.plugins.draw();
_state.draw();
if (FlxG.renderTile)
{
FlxG.cameras.render();
#if FLX_DEBUG
debugger.stats.drawCalls(FlxTilesheet._DRAWCALLS);
#end
}
FlxG.cameras.unlock();
FlxG.signals.postDraw.dispatch();
#if FLX_DEBUG
debugger.stats.flixelDraw(getTimer() - ticks);
#end
}
private dynamic function getTimer():Int
{
return Lib.getTimer();
}
}