<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.spheredev.org/index.php?action=history&amp;feed=atom&amp;title=API%3ASphere.now</id>
	<title>API:Sphere.now - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.spheredev.org/index.php?action=history&amp;feed=atom&amp;title=API%3ASphere.now"/>
	<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;action=history"/>
	<updated>2026-09-23T20:33:39Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.9</generator>
	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;diff=10158&amp;oldid=prev</id>
		<title>Bruce Pascoe: Clarify some stuff, add note on odometer rollover</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;diff=10158&amp;oldid=prev"/>
		<updated>2017-11-15T05:55:45Z</updated>

		<summary type="html">&lt;p&gt;Clarify some stuff, add note on odometer rollover&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:55, 15 November 2017&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l13&quot;&gt;Line 13:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 13:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Description ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Description ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt;&#039;&#039;&#039; returns the number of complete &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;frames processed &lt;/del&gt;since the calling game started.  Therefore, on the very first frame this will return 0, on the next frame 1, and so on.  &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;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 &lt;/del&gt;&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt; as a frame-perfect timer &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;in cases where using &lt;/del&gt;wall-clock time &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;(e.g. &amp;lt;tt&amp;gt;Date.now()&amp;lt;/tt&amp;gt;) is not desirable&lt;/del&gt;.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&#039;&#039;&#039;&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt;&#039;&#039;&#039; returns the number of complete &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;event loop turns &lt;/ins&gt;since the calling game started&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, each event loop turn corresponding to a frame&lt;/ins&gt;.  Therefore, on the very first frame this will return 0, on the next frame 1, and so on.  &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;Because &lt;/ins&gt;&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt; &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;counts frames instead of wall-clock time, this allows you to use it &lt;/ins&gt;as a frame-perfect timer&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, which is often more predictable than &lt;/ins&gt;wall-clock time&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;, particularly if the game begins dropping frames&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;By default, Sphere &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;will regulate updates so &lt;/del&gt;that 60 frames &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;will be &lt;/del&gt;processed every second (60 FPS).  Your game can change that by setting the value of &amp;lt;tt&amp;gt;[[API:Sphere.frameRate|Sphere.frameRate]]&amp;lt;/tt&amp;gt; to something other than 60.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;By default, Sphere &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;regulates the event loop such &lt;/ins&gt;that 60 frames &lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;are &lt;/ins&gt;processed every second (60 FPS).  Your game can change that by setting the value of &amp;lt;tt&amp;gt;[[API:Sphere.frameRate|Sphere.frameRate]]&amp;lt;/tt&amp;gt; to something other than 60.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Parameters ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Parameters ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l23&quot;&gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Return Value ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== Return Value ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The number of complete frames processed since the game started running.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The number of complete frames processed since the game started running&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.  This value will roll over, like an odometer, after exactly 4,294,967,296 frames.  This is not a practical concern: running at 60 frames per second, your game would need to run continuously, &#039;&#039;for 2 years straight&#039;&#039;, before the counter will roll over&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== See Also ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== See Also ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Bruce Pascoe</name></author>
	</entry>
	<entry>
		<id>http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;diff=10157&amp;oldid=prev</id>
		<title>Bruce Pascoe: Add Sphere.now() page</title>
		<link rel="alternate" type="text/html" href="http://wiki.spheredev.org/index.php?title=API:Sphere.now&amp;diff=10157&amp;oldid=prev"/>
		<updated>2017-11-02T16:32:51Z</updated>

		<summary type="html">&lt;p&gt;Add Sphere.now() page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{DISPLAYTITLE:Sphere.now()}}&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;&amp;#039;&amp;#039;&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt;&amp;#039;&amp;#039;&amp;#039; [[API:Functions|Core API]] function returns the number of frames processed since the engine started running.&lt;br /&gt;
&lt;br /&gt;
===== Usage =====&lt;br /&gt;
&lt;br /&gt;
 &amp;#039;&amp;#039;frames_elapsed&amp;#039;&amp;#039; = &amp;#039;&amp;#039;&amp;#039;Sphere.now&amp;#039;&amp;#039;&amp;#039;();&lt;br /&gt;
&lt;br /&gt;
__TOC__&lt;br /&gt;
&lt;br /&gt;
== API Information ==&lt;br /&gt;
&lt;br /&gt;
=== Description ===&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;&amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt;&amp;#039;&amp;#039;&amp;#039; 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 &amp;lt;tt&amp;gt;Sphere.now()&amp;lt;/tt&amp;gt; as a frame-perfect timer in cases where using wall-clock time (e.g. &amp;lt;tt&amp;gt;Date.now()&amp;lt;/tt&amp;gt;) is not desirable.&lt;br /&gt;
&lt;br /&gt;
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 &amp;lt;tt&amp;gt;[[API:Sphere.frameRate|Sphere.frameRate]]&amp;lt;/tt&amp;gt; to something other than 60.&lt;br /&gt;
&lt;br /&gt;
=== Parameters ===&lt;br /&gt;
&lt;br /&gt;
This function has no parameters.&lt;br /&gt;
&lt;br /&gt;
=== Return Value ===&lt;br /&gt;
&lt;br /&gt;
The number of complete frames processed since the game started running.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;&lt;br /&gt;
* [[API:Sphere.frameRate|Sphere.frameRate]]&lt;br /&gt;
&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Sphere 2 API]]&lt;/div&gt;</summary>
		<author><name>Bruce Pascoe</name></author>
	</entry>
</feed>