Files
GDevelop/GDJS/Runtime/timer.js
T
Florian 50ee292342 Added TimeExtension.
Added imageManager to Runtime ( TODO : Images not properly loaded at startup ).
Added support for scaling Sprite objects.

TODO : Polygon collision testing is too expensive. Add a check for basic bounding box and avoid recreating temporaries when returning hit boxes.
TODO : Avoid creating forces each frame.
TODO : Recycle objects.

git-svn-id: svn://localhost@997 8062f311-0dae-4547-b526-b8ab9ac864a5
2013-05-19 22:23:44 +00:00

76 lines
1.4 KiB
JavaScript

/**
* Represents a timer which must be updated manually.
*
* @class timer
* @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;
}