The Timer class acts as a global time measurement that can be accessed from various parts of the engine. These three values are representation of the same underlying calculus: tmod, dt, fps

Static variables

@:value(1 / wantedFPS)staticdt:Float = 1 / wantedFPS

The smoothed elapsed time (in seconds).

@:value(0.)staticread onlyelapsedTime:Float = 0.

The amount of time (unsmoothed) that was spent since the last frame.

@:value(0)staticframeCount:Int = 0

A frame counter, increases on each call to update()

@:value(haxe.Timer.stamp())staticread onlylastTimeStamp:Float = haxe.Timer.stamp()

The last timestamp in which update() function was called.

@:value(0.5)staticmaxDeltaTime:Float = 0.5

The maximum amount of time between two frames (in seconds). If the time exceed this amount, Timer will consider these lags are to be ignored. Default : 0.5

@:value(0.95)staticsmoothFactor:Float = 0.95

The smoothing done between frames. A smoothing of 0 gives "real time" values, higher values will smooth the results for tmod/dt/fps over frames using the formula dt = lerp(elapsedTime, dt, smoothFactor) Default : 0 on HashLink, 0.95 on other platforms

statictmod:Float

The smoothed frame modifier, based on wantedFPS. Its value is the same as dt/wantedFPS Allows to express movements in terms of pixels-per-frame-at-wantedFPS instead of per second.

@:value(60.)staticwantedFPS:Float = 60.

The FPS on which "tmod" have values are based on. Can be freely configured if your gameplay runs at a different speed. Default : 60

Static methods

staticfps():Float

The current smoothed FPS.

staticreset():Void

Similar as skip() but also reset dt to default value. Can be used when starting a new game if you want to discard any previous measurement.

staticskip():Void

After some loading / long processing, call skip() in order to prevent it from impacting your smoothed values.

staticupdate():Void

Update the timer calculus on each frame. This is automatically called by hxd.App