Skip to content

Commit 258b549

Browse files
committed
Stubbed Net and Debug so they can be properly excluded during a custom build.
1 parent 8290e8c commit 258b549

8 files changed

Lines changed: 156 additions & 22 deletions

File tree

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ module.exports = function (grunt) {
4848
'retrofont': { 'description': 'Retro Fonts Game Object', 'optional': true, 'stub': false },
4949
'system': { 'description': 'System Classes', 'optional': false, 'stub': false },
5050
'math': { 'description': 'Math, QuadTree and RND', 'optional': false, 'stub': false },
51-
'net': { 'description': 'Network Class', 'optional': true, 'stub': false },
51+
'net': { 'description': 'Network Class', 'optional': true, 'stub': true },
5252
'tweens': { 'description': 'Tween Manager', 'optional': true, 'stub': true },
5353
'time': { 'description': 'Time and Clock Manager', 'optional': false, 'stub': false },
5454
'animation': { 'description': 'Animation and Frame Manager', 'optional': false, 'stub': false },
5555
'loader': { 'description': 'Loader and Cache', 'optional': false, 'stub': false },
5656
'sound': { 'description': 'Sound Support (Web Audio and HTML Audio)', 'optional': true, 'stub': true },
57-
'debug': { 'description': 'Debug Class', 'optional': true, 'stub': false },
57+
'debug': { 'description': 'Debug Class', 'optional': true, 'stub': true },
5858
'utils': { 'description': 'Core Utilities', 'optional': false, 'stub': false },
5959
'physics': { 'description': 'Physics Manager', 'optional': false, 'stub': false },
6060
'arcade': { 'description': 'Arcade Physics', 'optional': true, 'stub': false },

src/core/Game.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
/**
88
* This is where the magic happens. The Game object is the heart of your game,
99
* providing quick access to common functions and handling the boot process.
10-
*
10+
*
1111
* "Hell, there are no rules here - we're trying to accomplish something."
1212
* Thomas A. Edison
1313
*
@@ -211,7 +211,7 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
211211
* @property {Phaser.Physics} physics - Reference to the physics manager.
212212
*/
213213
this.physics = null;
214-
214+
215215
/**
216216
* @property {Phaser.PluginManager} plugins - Reference to the plugin manager.
217217
*/
@@ -544,6 +544,7 @@ Phaser.Game.prototype = {
544544
this.particles = new Phaser.Particles(this);
545545
this.plugins = new Phaser.PluginManager(this);
546546
this.net = new Phaser.Net(this);
547+
this.debug = new Phaser.Utils.Debug(this, this.config['enableDebug']);
547548

548549
this.time.boot();
549550
this.stage.boot();
@@ -552,16 +553,7 @@ Phaser.Game.prototype = {
552553
this.input.boot();
553554
this.sound.boot();
554555
this.state.boot();
555-
556-
if (this.config['enableDebug'])
557-
{
558-
this.debug = new Phaser.Utils.Debug(this);
559-
this.debug.boot();
560-
}
561-
else
562-
{
563-
this.debug = { preUpdate: function () {}, update: function () {}, reset: function () {} };
564-
}
556+
this.debug.boot();
565557

566558
this.showDebugHeader();
567559

@@ -732,7 +724,7 @@ Phaser.Game.prototype = {
732724
if (this.renderType !== Phaser.HEADLESS)
733725
{
734726
this.stage.smoothed = this.antialias;
735-
727+
736728
Phaser.Canvas.addToDOM(this.canvas, this.parent, false);
737729
Phaser.Canvas.setTouchAction(this.canvas);
738730
}
@@ -754,7 +746,7 @@ Phaser.Game.prototype = {
754746
{
755747
this.updateLogic(1.0 / this.time.desiredFps);
756748

757-
// Sync the scene graph after _every_ logic update to account for moved game objects
749+
// Sync the scene graph after _every_ logic update to account for moved game objects
758750
this.stage.updateTransform();
759751

760752
// call the game render update exactly once every frame

src/stubs/Debug.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/**
2+
* @author Steven Rogers <soldoutactivist@gmail.com>
3+
* @copyright 2015 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* This is a stub for the Phaser Debug Class.
9+
* It allows you to exclude the default Debug from your build, without making Game crash.
10+
*/
11+
12+
var debugNoop = function () {};
13+
14+
Phaser.Utils.Debug = debugNoop;
15+
16+
Phaser.Utils.Debug.prototype = {
17+
isDisabled: true,
18+
19+
boot: debugNoop,
20+
preUpdate: debugNoop,
21+
reset: debugNoop,
22+
start: debugNoop,
23+
stop: debugNoop,
24+
line: debugNoop,
25+
soundInfo: debugNoop,
26+
cameraInfo: debugNoop,
27+
timer: debugNoop,
28+
pointer: debugNoop,
29+
spriteInputInfo: debugNoop,
30+
key: debugNoop,
31+
inputInfo: debugNoop,
32+
spriteBounds: debugNoop,
33+
ropeSegments: debugNoop,
34+
spriteInfo: debugNoop,
35+
spriteCoords: debugNoop,
36+
lineInfo: debugNoop,
37+
pixel: debugNoop,
38+
geom: debugNoop,
39+
rectangle: debugNoop,
40+
text: debugNoop,
41+
quadTree: debugNoop,
42+
body: debugNoop,
43+
bodyInfo: debugNoop,
44+
box2dWorld: debugNoop,
45+
box2dBody: debugNoop
46+
};
47+
48+
Phaser.Utils.Debug.prototype.constructor = Phaser.Utils.Debug;

src/stubs/Net.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/**
2+
* @author Steven Rogers <soldoutactivist@gmail.com>
3+
* @copyright 2015 Photon Storm Ltd.
4+
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
5+
*/
6+
7+
/**
8+
* This is a stub for the Phaser Net Class.
9+
* It allows you to exclude the default Net from your build, without making Game crash.
10+
*/
11+
12+
var netNoop = function () {};
13+
14+
Phaser.Net = netNoop;
15+
16+
Phaser.Net.prototype = {
17+
isDisabled: true,
18+
19+
getHostName: netNoop,
20+
checkDomainName: netNoop,
21+
updateQueryString: netNoop,
22+
getQueryString: netNoop,
23+
decodeURI: netNoop
24+
};
25+
26+
Phaser.Net.prototype.constructor = Phaser.Net;

0 commit comments

Comments
 (0)