mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 13:13:43 +00:00
Added FrameDebugger into the mix.
This commit is contained in:
parent
5ceb9914b9
commit
06ed961e81
3 changed files with 91 additions and 0 deletions
|
@ -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
89
src/core/FrameDebugger.js
Normal 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;
|
||||
|
||||
}
|
||||
|
||||
};
|
|
@ -14,5 +14,6 @@
|
|||
"src/core/FlexGrid.js",
|
||||
"src/core/FlexLayer.js",
|
||||
"src/core/ScaleManager.js",
|
||||
"src/core/FrameDebugger.js",
|
||||
"src/core/Game.js"
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue