Timer.js (system script)

From Spheriki

Jump to: navigation, search

The timer.js system script provides a Timer object, which is a counter that will start at 0 when created and increase by 1000 every second.


Contents

Usage

RequireSystemScript("timer.js");


Variables and functions of timer.js

  • object constructor Timer()
    • methods of objects created from it:
      • getMilliseconds() - returns the elapsed time since the creation of the timer object.
      • pause() - pauses the timer.
      • unpause() - resumes the timer.


Example

This will create a timer object:

RequireSystemScript("timer.js");
var MyTimer = new Timer();

Later, to get its state, use:

var CurrentState = MyTimer.getMilliseconds()

To reset the timer, simply create a new object over the old one:

MyTimer = new Timer();


Notes

  • SetFrameRate() usually suffices when it comes to time animations. You won't need timer.js for it.


See also

Personal tools