Added FrameDebugger into the mix.

This commit is contained in:
photonstorm 2015-09-15 12:19:03 +01:00
parent 5ceb9914b9
commit 06ed961e81
3 changed files with 91 additions and 0 deletions

View file

@ -135,6 +135,7 @@ EOL;
<script src="$path/src/core/FlexGrid.js"></script>
<script src="$path/src/core/FlexLayer.js"></script>
<script src="$path/src/core/ScaleManager.js"></script>
<script src="$path/src/core/FrameDebugger.js"></script>
<script src="$path/src/core/Game.js"></script>
<script src="$path/src/input/Input.js"></script>

89
src/core/FrameDebugger.js Normal file
View file

@ -0,0 +1,89 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2015 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
/**
*
*
* @class Phaser.FrameDebugger
* @constructor
* @param {Phaser.Game} game - Reference to the currently running game.
*/
Phaser.FrameDebugger = function (game) {
/**
* @property {Phaser.Game} game - A reference to the currently running Game.
*/
this.game = game;
this.on = false;
// Single frame
this.frame = [];
// Then at the end of the frame we'll add it to the log
this.log = [];
this.count = 0;
this.max = 1;
};
Phaser.FrameDebugger.prototype = {
start: function () {
this.frame = [Date.now()];
},
stop: function () {
this.frame.push(Date.now());
this.log.push(this.frame);
this.count++;
if (this.count === this.max)
{
this.finish();
}
}
finish: function () {
this.on = false;
console.log(this.log);
debugger;
},
record: function (max) {
if (max === undefined) { max = 1; }
if (this.on) { return; }
this.reset();
this.on = true;
this.max = max;
},
reset: function () {
this.frame = [];
this.log = [];
this.count = 0;
this.max = 1;
}
};

View file

@ -14,5 +14,6 @@
"src/core/FlexGrid.js",
"src/core/FlexLayer.js",
"src/core/ScaleManager.js",
"src/core/FrameDebugger.js",
"src/core/Game.js"
]