Skip to content

Commit

Permalink
added _startTime var to FlxGame to handle specifics of Lib.getTimer()…
Browse files Browse the repository at this point in the history
… on js target
  • Loading branch information
Beeblerox committed Jun 5, 2016
1 parent 79f2df8 commit f7aa1c9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion flixel/FlxGame.hx
Expand Up @@ -97,6 +97,12 @@ class FlxGame extends Sprite
* 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.
Expand Down Expand Up @@ -282,6 +288,7 @@ class FlxGame extends Sprite
removeEventListener(Event.ADDED_TO_STAGE, create);

_total = getTimer();
_startTime = _total;

#if desktop
FlxG.fullscreen = _startFullscreen;
Expand Down Expand Up @@ -492,7 +499,7 @@ class FlxGame extends Sprite
*/
private function onEnterFrame(_):Void
{
ticks = getTimer();
ticks = getTimer() - _startTime;
_elapsedMS = ticks - _total;
_total = ticks;

Expand Down

1 comment on commit f7aa1c9

@Gama11
Copy link
Member

@Gama11 Gama11 commented on f7aa1c9 Jun 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This broke HTML5 builds in debug mode, since there are two more places where ticks is set in that case. Fixed in 94fa8e4.

Please sign in to comment.