API:Sphere.now

From Spherical
Revision as of 16:32, 2 November 2017 by Bruce Pascoe (talk | contribs) (Add Sphere.now() page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


The Sphere.now() Core API function returns the number of frames processed since the engine started running.

Usage
frames_elapsed = Sphere.now();

API Information

Description

Sphere.now() returns the number of complete frames processed since the calling game started. Therefore, on the very first frame this will return 0, on the next frame 1, and so on. Specifically the return value is the number of full event loop turns, which by definition is the same as the number of updates performed. This allows you to use Sphere.now() as a frame-perfect timer in cases where using wall-clock time (e.g. Date.now()) is not desirable.

By default, Sphere will regulate updates so that 60 frames will be processed every second (60 FPS). Your game can change that by setting the value of Sphere.frameRate to something other than 60.

Parameters

This function has no parameters.

Return Value

The number of complete frames processed since the game started running.

See Also