Phaser.Time = function (game){ this.game = game; } ; Phaser.Time.prototype = { game: null , _started: 0, _timeLastSecond: 0, _pauseStarted: 0, physicsElapsed: 0, time: 0, pausedTime: 0, now: 0, delta: 0, fps: 0, fpsMin: 1000, fpsMax: 0, msMin: 1000, msMax: 0, frames: 0, pauseDuration: 0, totalElapsedSeconds: function (){ return (this.now - this._started) * 0.001; } , update: function (raf){ this.now = raf; this.delta = this.now - this.time; this.msMin = Math.min(this.msMin, this.delta); this.msMax = Math.max(this.msMax, this.delta); this.frames++ ; if (this.now > this._timeLastSecond + 1000) { this.fps = Math.round((this.frames * 1000) / (this.now - this._timeLastSecond)); this.fpsMin = Math.min(this.fpsMin, this.fps); this.fpsMax = Math.max(this.fpsMax, this.fps); this._timeLastSecond = this.now; this.frames = 0; } this.time = this.now; this.physicsElapsed = 1 * (this.delta / 1000); if (this.game.paused) { this.pausedTime = this.now - this._pauseStarted; } } , gamePaused: function (){ this._pauseStarted = this.now; } , gameResumed: function (){ this.delta = 0; this.physicsElapsed = 0; this.time = Date.now(); this.pauseDuration = this.pausedTime; } , elapsedSince: function (since){ return this.now - since; } , elapsedSecondsSince: function (since){ return (this.now - since) * 0.001; } , reset: function (){ this._started = this.now; } } ;