Files
GDevelop/GDJS/Runtime/timer.js
T
Florian cb375aaac3 Moved events related functions to gdjs.evtTools.
Updated a bit the doc.

git-svn-id: svn://localhost@1058 8062f311-0dae-4547-b526-b8ab9ac864a5
2013-06-20 18:26:04 +00:00

82 lines
1.5 KiB
JavaScript

/*
* Game Develop JS Platform
* 2013 Florian Rival (Florian.Rival@gmail.com)
*/
/**
* Represents a timer which must be updated manually.
*
* @class timer
* @namespace gdjs
* @constructor
*/
gdjs.timer = function(name)
{
var that = {};
var my = {};
my.name = name;
my.time = 0;
my.paused = false;
/**
* Get the name of the timer
* @method getName
* @return {String} The name of the timer
*/
that.getName = function() {
return my.name;
}
/**
* Get the time elapsed
* @method getTime
* @return {String} The time of the timer
*/
that.getTime = function() {
return my.time;
}
/**
* Notify the timer that some time elapsed.
* @method updateTime
*/
that.updateTime = function(time) {
if ( !my.paused ) my.time += time;
}
/**
* Change the time.
* @method setTime
*/
that.setTime = function(time) {
my.time = time;
}
/**
* Set time to zero.
* @method reset
*/
that.reset = function(time) {
that.setTime(0);
}
/**
* Set if the timer is paused.
* @method setPaused
*/
that.setPaused = function(enable) {
my.paused = enable;
}
/**
* Check if the timer is paused.
* @method isPaused
*/
that.isPaused = function() {
return my.paused;
}
return that;
}