1 /** 2 * @class clock 3 * @extends component 4 * @description 5 * An component that keeps track of time with millisecond resolution. Instantiates with {@link sandboxe.clock.create()} </br></br> 6 * 7 * Grants functionality similar to using a stopwatch. Note that all properties 8 * are readonly. Writing to them will have no effect and will not persist.</br></br> 9 * 10 * Known {@link component} events:</br> 11 * <pre> 12 * - clock-step: Called every step when the clock is active. 13 * - clock-draw: Called every draw when the clock is active. 14 * - clock-expire: Called when the clock expires 15 * </pre> 16 * 17 * 18 */ 19 function clock() { 20 21 /** 22 * Resets the timer with the time it should expire in milliseconds. 23 * @param {Number} time If specified, sets the new duration for the timer. If excluded, the timer has no time limit. 24 */ 25 this.set = function(){}; 26 27 /** 28 * Resets the timer with the time it had previously 29 */ 30 this.reset = function(){}; 31 32 /** 33 * Pauses the timer. 34 */ 35 this.pause = function(){}; 36 37 /** 38 * Resumes the timer from the pause state. 39 */ 40 this.resume = function(){}; 41 42 43 44 /** 45 * Returns the number of milliseconds since the clock was last set. 46 * @type {Number} 47 */ 48 this.timeSince = 0.0; 49 50 /** 51 * Returns the number of milliseconds left until the clock expires 52 * @type {Number} 53 */ 54 this.timeLeft = 0.0; 55 56 /** 57 * Returns duration of the timer in milliseconds. 58 * @type {Number} 59 */ 60 this.duration = 0.0; 61 62 /** 63 * Returns whether the clock as expired. 64 * @type {Number} 65 */ 66 this.expired = 0.0; 67 68 /** 69 * Returns whether the clock is in a paused state. 70 * @type {Number} 71 */ 72 this.paused = 0.0; 73 74 75 76 77 78 return this; 79 }