Skip to content

Commit e607d14

Browse files
committed
Added jsdocs.
1 parent 2813ac8 commit e607d14

3 files changed

Lines changed: 113 additions & 25 deletions

File tree

src/boot/Game.js

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var DOMContentLoaded = require('../dom/DOMContentLoaded');
1818
var EventEmitter = require('eventemitter3');
1919
var InputManager = require('../input/InputManager');
2020
var NOOP = require('../utils/NOOP');
21-
var PluginManager = require('../boot/PluginManager');
21+
var PluginManager = require('./PluginManager');
2222
var SceneManager = require('../scene/SceneManager');
2323
var SoundManagerCreator = require('../sound/SoundManagerCreator');
2424
var TextureManager = require('../textures/TextureManager');
@@ -50,9 +50,11 @@ var Game = new Class({
5050
{
5151
/**
5252
* The parsed Game Configuration object.
53+
*
5354
* The values stored within this object are read-only and should not be changed at run-time.
5455
*
55-
* @property {Phaser.Boot.Config} config
56+
* @name Phaser.Game#config
57+
* @type {Phaser.Boot.Config}
5658
* @readOnly
5759
* @since 3.0.0
5860
*/
@@ -61,31 +63,35 @@ var Game = new Class({
6163
/**
6264
* A reference to either the Canvas or WebGL Renderer that this Game is using.
6365
*
64-
* @property {Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer} renderer
66+
* @name Phaser.Game#renderer
67+
* @type {Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer}
6568
* @since 3.0.0
6669
*/
6770
this.renderer = null;
6871

6972
/**
7073
* A reference to the HTML Canvas Element on which the renderer is drawing.
7174
*
72-
* @property {HTMLCanvasElement} canvas
75+
* @name Phaser.Game#canvas
76+
* @type {HTMLCanvasElement}
7377
* @since 3.0.0
7478
*/
7579
this.canvas = null;
7680

7781
/**
7882
* A reference to the Canvas Rendering Context belonging to the Canvas Element this game is rendering to.
7983
*
80-
* @property {CanvasRenderingContext2D} context
84+
* @name Phaser.Game#context
85+
* @type {CanvasRenderingContext2D}
8186
* @since 3.0.0
8287
*/
8388
this.context = null;
8489

8590
/**
8691
* A flag indicating when this Game instance has finished its boot process.
8792
*
88-
* @property {boolean} isBooted
93+
* @name Phaser.Game#isBooted
94+
* @type {boolean}
8995
* @readOnly
9096
* @since 3.0.0
9197
*/
@@ -94,7 +100,8 @@ var Game = new Class({
94100
/**
95101
* A flag indicating if this Game is currently running its game step or not.
96102
*
97-
* @property {boolean} isRunning
103+
* @name Phaser.Game#isRunning
104+
* @type {boolean}
98105
* @readOnly
99106
* @since 3.0.0
100107
*/
@@ -103,7 +110,8 @@ var Game = new Class({
103110
/**
104111
* An Event Emitter which is used to broadcast game-level events from the global systems.
105112
*
106-
* @property {EventEmitter} events
113+
* @name Phaser.Game#events
114+
* @type {EventEmitter}
107115
* @since 3.0.0
108116
*/
109117
this.events = new EventEmitter();
@@ -113,7 +121,8 @@ var Game = new Class({
113121
*
114122
* The Animation Manager is a global system responsible for managing all animations used within your game.
115123
*
116-
* @property {Phaser.Animations.AnimationManager} anims
124+
* @name Phaser.Game#anims
125+
* @type {Phaser.Animations.AnimationManager}
117126
* @since 3.0.0
118127
*/
119128
this.anims = new AnimationManager(this);
@@ -123,7 +132,8 @@ var Game = new Class({
123132
*
124133
* The Texture Manager is a global system responsible for managing all textures being used by your game.
125134
*
126-
* @property {Phaser.Textures.TextureManager} textures
135+
* @name Phaser.Game#textures
136+
* @type {Phaser.Textures.TextureManager}
127137
* @since 3.0.0
128138
*/
129139
this.textures = new TextureManager(this);
@@ -133,15 +143,17 @@ var Game = new Class({
133143
*
134144
* The Cache Manager is a global system responsible for caching, accessing and releasing external game assets.
135145
*
136-
* @property {Phaser.Cache.CacheManager} cache
146+
* @name Phaser.Game#cache
147+
* @type {Phaser.Cache.CacheManager}
137148
* @since 3.0.0
138149
*/
139150
this.cache = new CacheManager(this);
140151

141152
/**
142153
* [description]
143154
*
144-
* @property {Phaser.Data.DataManager} registry
155+
* @name Phaser.Game#registry
156+
* @type {Phaser.Data.DataManager}
145157
* @since 3.0.0
146158
*/
147159
this.registry = new DataManager(this);
@@ -151,7 +163,8 @@ var Game = new Class({
151163
*
152164
* The Input Manager is a global system responsible for the capture of browser-level input events.
153165
*
154-
* @property {Phaser.Input.InputManager} input
166+
* @name Phaser.Game#input
167+
* @type {Phaser.Input.InputManager}
155168
* @since 3.0.0
156169
*/
157170
this.input = new InputManager(this, this.config);
@@ -161,7 +174,8 @@ var Game = new Class({
161174
*
162175
* The Scene Manager is a global system responsible for creating, modifying and updating the Scenes in your game.
163176
*
164-
* @property {Phaser.Scenes.SceneManager} scene
177+
* @name Phaser.Game#scene
178+
* @type {Phaser.Scenes.SceneManager}
165179
* @since 3.0.0
166180
*/
167181
this.scene = new SceneManager(this, this.config.sceneConfig);
@@ -172,7 +186,8 @@ var Game = new Class({
172186
* Contains information about the device running this game, such as OS, browser vendor and feature support.
173187
* Used by various systems to determine capabilities and code paths.
174188
*
175-
* @property {Phaser.Device} device
189+
* @name Phaser.Game#device
190+
* @type {Phaser.Device}
176191
* @since 3.0.0
177192
*/
178193
this.device = Device;
@@ -182,7 +197,8 @@ var Game = new Class({
182197
*
183198
* The Sound Manager is a global system responsible for the playback and updating of all audio in your game.
184199
*
185-
* @property {Phaser.BaseSoundManager} sound
200+
* @name Phaser.Game#sound
201+
* @type {Phaser.BaseSoundManager}
186202
* @since 3.0.0
187203
*/
188204
this.sound = SoundManagerCreator.create(this);
@@ -193,7 +209,8 @@ var Game = new Class({
193209
* The Time Step is a global system responsible for setting-up and responding to the browser frame events, processing
194210
* them and calculating delta values. It then automatically calls the game step.
195211
*
196-
* @property {Phaser.Boot.TimeStep} loop
212+
* @name Phaser.Game#loop
213+
* @type {Phaser.Boot.TimeStep}
197214
* @since 3.0.0
198215
*/
199216
this.loop = new TimeStep(this, this.config.fps);
@@ -204,7 +221,8 @@ var Game = new Class({
204221
* The Plugin Manager is a global system that allows plugins to register themselves with it, and can then install
205222
* those plugins into Scenes as required.
206223
*
207-
* @property {Phaser.Plugins.PluginManager} plugins
224+
* @name Phaser.Game#plugins
225+
* @type {Phaser.Boot.PluginManager}
208226
* @since 3.0.0
209227
*/
210228
this.plugins = new PluginManager(this, this.config);
@@ -213,7 +231,9 @@ var Game = new Class({
213231
* The `onStepCallback` is a callback that is fired each time the Time Step ticks.
214232
* It is set automatically when the Game boot process has completed.
215233
*
216-
* @property {function} onStepCallback
234+
* @name Phaser.Game#onStepCallback
235+
* @type {function}
236+
* @private
217237
* @since 3.0.0
218238
*/
219239
this.onStepCallback = NOOP;

src/boot/PluginManager.js

Lines changed: 71 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,57 @@ var Class = require('../utils/Class');
88

99
var plugins = {};
1010

11+
/**
12+
* @classdesc
13+
* The PluginManager is global and belongs to the Game instance, not a Scene.
14+
* It handles the installation and removal of all global and Scene based plugins.
15+
* Plugins automatically register themselves with the PluginManager in their respective classes.
16+
*
17+
* @class PluginManager
18+
* @memberOf Phaser.Boot
19+
* @constructor
20+
* @since 3.0.0
21+
*
22+
* @param {Phaser.Game} game - [description]
23+
*/
1124
var PluginManager = new Class({
1225

1326
initialize:
1427

15-
// The PluginManager is global and belongs to the Game instance, not a Scene.
1628
function PluginManager (game)
1729
{
30+
/**
31+
* [description]
32+
*
33+
* @name Phaser.Boot.PluginManager#game
34+
* @type {Phaser.Game}
35+
* @since 3.0.0
36+
*/
1837
this.game = game;
1938

2039
game.events.once('boot', this.boot, this);
2140
},
2241

42+
/**
43+
* [description]
44+
*
45+
* @method Phaser.Boot.PluginManager#boot
46+
* @since 3.0.0
47+
*/
2348
boot: function ()
2449
{
2550
this.game.events.once('destroy', this.destroy, this);
2651
},
2752

53+
/**
54+
* [description]
55+
*
56+
* @method Phaser.Boot.PluginManager#installGlobal
57+
* @since 3.0.0
58+
*
59+
* @param {Phaser.Scenes.Systems} sys - [description]
60+
* @param {array} globalPlugins - [description]
61+
*/
2862
installGlobal: function (sys, globalPlugins)
2963
{
3064
var game = sys.game;
@@ -51,6 +85,15 @@ var PluginManager = new Class({
5185
}
5286
},
5387

88+
/**
89+
* [description]
90+
*
91+
* @method Phaser.Boot.PluginManager#installLocal
92+
* @since 3.0.0
93+
*
94+
* @param {Phaser.Scenes.Systems} sys - [description]
95+
* @param {array} scenePlugins - [description]
96+
*/
5497
installLocal: function (sys, scenePlugins)
5598
{
5699
var scene = sys.scene;
@@ -86,23 +129,45 @@ var PluginManager = new Class({
86129
}
87130
},
88131

132+
/**
133+
* [description]
134+
*
135+
* @method Phaser.Boot.PluginManager#remove
136+
* @since 3.0.0
137+
*
138+
* @param {string} key - [description]
139+
*/
89140
remove: function (key)
90141
{
91142
delete plugins[key];
92143
},
93144

145+
/**
146+
* [description]
147+
*
148+
* @method Phaser.Boot.PluginManager#destroy
149+
* @since 3.0.0
150+
*/
94151
destroy: function ()
95152
{
96153
this.game = null;
97154
}
98155

99156
});
100157

101-
// Static method called directly by the Plugins
102-
// Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin)
103-
// Plugin is the object to instantiate to create the plugin
104-
// Mapping is what the plugin is injected into the Scene.Systems as (i.e. input)
105-
158+
/**
159+
* Static method called directly by the Plugins
160+
* Key is a reference used to get the plugin from the plugins object (i.e. InputPlugin)
161+
* Plugin is the object to instantiate to create the plugin
162+
* Mapping is what the plugin is injected into the Scene.Systems as (i.e. input)
163+
*
164+
* @name PluginManager.register
165+
* @since 3.0.0
166+
*
167+
* @param {string} key - [description]
168+
* @param {object} plugin - [description]
169+
* @param {string} mapping - [description]
170+
*/
106171
PluginManager.register = function (key, plugin, mapping)
107172
{
108173
plugins[key] = { plugin: plugin, mapping: mapping };

src/plugins.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
55
*/
66

7+
/**
8+
* @namespace Phaser.Plugins
9+
*/
710
var Plugins = {
811

912
/**

0 commit comments

Comments
 (0)