mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-07-24 20:05:39 -04:00
50ee292342
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
76 lines
1.4 KiB
JavaScript
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;
|
|
} |