From 06ed961e81fac9ebd44fb55b54021de2659b2a67 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 15 Sep 2015 12:19:03 +0100 Subject: [PATCH] Added FrameDebugger into the mix. --- build/config.php | 1 + src/core/FrameDebugger.js | 89 +++++++++++++++++++++++++++++++++++++++ tasks/manifests/core.json | 1 + 3 files changed, 91 insertions(+) create mode 100644 src/core/FrameDebugger.js diff --git a/build/config.php b/build/config.php index 3a1e3bb15..1c4a9b36b 100644 --- a/build/config.php +++ b/build/config.php @@ -135,6 +135,7 @@ EOL; + diff --git a/src/core/FrameDebugger.js b/src/core/FrameDebugger.js new file mode 100644 index 000000000..d6d0eede7 --- /dev/null +++ b/src/core/FrameDebugger.js @@ -0,0 +1,89 @@ +/** +* @author Richard Davey +* @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; + + } + +}; \ No newline at end of file diff --git a/tasks/manifests/core.json b/tasks/manifests/core.json index a894db656..e0242ae6b 100644 --- a/tasks/manifests/core.json +++ b/tasks/manifests/core.json @@ -14,5 +14,6 @@ "src/core/FlexGrid.js", "src/core/FlexLayer.js", "src/core/ScaleManager.js", + "src/core/FrameDebugger.js", "src/core/Game.js" ]