Finish document for Time, Tween, Animation, AnimationLoader, Frame.

This commit is contained in:
Sean
2013-05-10 16:31:16 +01:00
committed by Richard Davey
parent e88c48641d
commit 00ef200914
5 changed files with 251 additions and 50 deletions
+78 -29
View File
@@ -10,6 +10,12 @@ module Phaser {
export class Time {
/**
* Time constructor
* Create a new <code>Time</code>.
*
* @param game {Phaser.Game} Current game instance.
*/
constructor(game: Game) {
this._started = Date.now();
@@ -18,32 +24,47 @@ module Phaser {
}
/**
* Local private reference to game.
*/
private _game: Game;
/**
* Time when this object created.
* @param {number}
*/
private _started: number;
/**
* Time scale factor.
* Set it to 0.5 for slow motion, to 2.0 makes game twice faster.
* @type {number}
*/
public timeScale: number = 1.0;
/**
* Elapsed since last frame.
* @type {number}
*/
public elapsed: number = 0;
/**
*
* @property time
* @type Number
*/
* Game time counter.
* @property time
* @type {number}
*/
public time: number = 0;
/**
*
* @property now
* @type Number
*/
* Time of current frame.
* @property now
* @type {number}
*/
public now: number = 0;
/**
*
* @property delta
* @type Number
*/
* Elapsed time since last frame.
* @property delta
* @type {number}
*/
public delta: number = 0;
/**
@@ -57,19 +78,47 @@ module Phaser {
}
/**
* Frames per second.
* @type {number}
*/
public fps: number = 0;
/**
* Minimal fps.
* @type {number}
*/
public fpsMin: number = 1000;
/**
* Maximal fps.
* @type {number}
*/
public fpsMax: number = 0;
/**
* Mininal duration between 2 frames.
* @type {number}
*/
public msMin: number = 1000;
/**
* Maximal duration between 2 frames.
* @type {number}
*/
public msMax: number = 0;
/**
* How many frames in last second.
* @type {number}
*/
public frames: number = 0;
/**
* Time of last second.
* @type {number}
*/
private _timeLastSecond: number = 0;
/**
*
* @method update
*/
* Update clock and calc fps.
* @method update
*/
public update() {
// Can we use performance.now() ?
@@ -102,11 +151,11 @@ module Phaser {
}
/**
*
* @method elapsedSince
* @param {Number} since
* @return {Number}
*/
* How long has passed since given time.
* @method elapsedSince
* @param {number} since The time you want to measure.
* @return {number} Duration between given time and now.
*/
public elapsedSince(since: number): number {
return this.now - since;
@@ -114,11 +163,11 @@ module Phaser {
}
/**
*
* @method elapsedSecondsSince
* @param {Number} since
* @return {Number}
*/
* How long has passed since give time (in seconds).
* @method elapsedSecondsSince
* @param {number} since The time you want to measure (in seconds).
* @return {number} Duration between given time and now (in seconds).
*/
public elapsedSecondsSince(since: number): number {
return (this.now - since) * 0.001;
@@ -126,9 +175,9 @@ module Phaser {
}
/**
*
* @method reset
*/
* Set the start time to now.
* @method reset
*/
public reset() {
this._started = this.now;