diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index b7ad5b276..5c571ed68 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -11,29 +11,93 @@ var NOOP = require('../utils/NOOP'); var Scene = require('./Scene'); var Systems = require('./Systems'); +/** + * @classdesc + * The Scene Systems class. + * + * This class is available from within a Scene under the property `sys`. + * It is responsible for managing all of the plugins a Scene has running, including the display list, and + * handling the update step and renderer. It also contains references to global systems belonging to Game. + * + * @class SceneManager + * @memberOf Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Game} game - The Phaser.Game instance this Scene Manager belongs to. + * @param {object} sceneConfig - Scene specific configuration settings. + */ var SceneManager = new Class({ initialize: function SceneManager (game, sceneConfig) { + /** + * [description] + * + * @name Phaser.Scenes.SceneManager#game + * @type {Phaser.Game} + * @since 3.0.0 + */ this.game = game; - // An object that maps the keys to the scene so we can quickly get a scene from a key without iteration + /** + * An object that maps the keys to the scene so we can quickly get a scene from a key without iteration. + * + * @name Phaser.Scenes.SceneManager#keys + * @type {object} + * @since 3.0.0 + */ this.keys = {}; - // The array in which all of the scenes are kept + /** + * The array in which all of the scenes are kept. + * + * @name Phaser.Scenes.SceneManager#scenes + * @type {array} + * @since 3.0.0 + */ this.scenes = []; - // Scenes pending to be added are stored in here until the manager has time to add it + /** + * Scenes pending to be added are stored in here until the manager has time to add it. + * + * @name Phaser.Scenes.SceneManager#_pending + * @type {array} + * @private + * @since 3.0.0 + */ this._pending = []; - // An array of scenes waiting to be started once the game has booted + /** + * An array of scenes waiting to be started once the game has booted. + * + * @name Phaser.Scenes.SceneManager#_start + * @type {array} + * @private + * @since 3.0.0 + */ this._start = []; - // An operations queue, because we don't manipulate the scenes array during processing + /** + * An operations queue, because we don't manipulate the scenes array during processing. + * + * @name Phaser.Scenes.SceneManager#_queue + * @type {array} + * @private + * @since 3.0.0 + */ this._queue = []; + /** + * The number of Scenes to process. + * + * @name Phaser.Scenes.SceneManager#_processing + * @type {integer} + * @private + * @since 3.0.0 + */ this._processing = 0; if (sceneConfig) @@ -197,9 +261,8 @@ var SceneManager = new Class({ * [description] * * @method Phaser.Scenes.SceneManager#bootScene - * @since 3.0.0 - * * @private + * @since 3.0.0 * * @param {Phaser.Scene} scene - [description] */ @@ -249,11 +312,10 @@ var SceneManager = new Class({ * [description] * * @method Phaser.Scenes.SceneManager#loadComplete + * @private * @since 3.0.0 * - * @private - * - * @param {object} event - [description] + * @param {object} loader - [description] */ loadComplete: function (loader) { @@ -266,11 +328,10 @@ var SceneManager = new Class({ * [description] * * @method Phaser.Scenes.SceneManager#payloadComplete + * @private * @since 3.0.0 * - * @private - * - * @param {object} event - [description] + * @param {object} loader - [description] */ payloadComplete: function (loader) { @@ -332,9 +393,8 @@ var SceneManager = new Class({ * [description] * * @method Phaser.Scenes.SceneManager#create - * @since 3.0.0 - * * @private + * @since 3.0.0 * * @param {Phaser.Scene} scene - [description] */ @@ -354,9 +414,8 @@ var SceneManager = new Class({ * [description] * * @method Phaser.Scenes.SceneManager#createSceneFromFunction - * @since 3.0.0 - * * @private + * @since 3.0.0 * * @param {string} key - [description] * @param {function} scene - [description] @@ -404,9 +463,8 @@ var SceneManager = new Class({ * [description] * * @method Phaser.Scenes.SceneManager#createSceneFromInstance - * @since 3.0.0 - * * @private + * @since 3.0.0 * * @param {string} key - [description] * @param {Phaser.Scene} newScene - [description] @@ -435,9 +493,8 @@ var SceneManager = new Class({ * [description] * * @method Phaser.Scenes.SceneManager#createSceneFromObject - * @since 3.0.0 - * * @private + * @since 3.0.0 * * @param {string} key - [description] * @param {object} sceneConfig - [description] @@ -510,9 +567,8 @@ var SceneManager = new Class({ * [description] * * @method Phaser.Scenes.SceneManager#getKey - * @since 3.0.0 - * * @private + * @since 3.0.0 * * @param {string} key - [description] * @param {Phaser.Scene|object|function} sceneConfig - [description] @@ -904,7 +960,7 @@ var SceneManager = new Class({ { if (this._processing) { - this._queue.push( { op: 'bringToTop', keyA: key, keyB: null }); + this._queue.push({ op: 'bringToTop', keyA: key, keyB: null }); } else { @@ -936,7 +992,7 @@ var SceneManager = new Class({ { if (this._processing) { - this._queue.push( { op: 'sendToBack', keyA: key, keyB: null }); + this._queue.push({ op: 'sendToBack', keyA: key, keyB: null }); } else { @@ -968,7 +1024,7 @@ var SceneManager = new Class({ { if (this._processing) { - this._queue.push( { op: 'moveDown', keyA: key, keyB: null }); + this._queue.push({ op: 'moveDown', keyA: key, keyB: null }); } else { @@ -1002,7 +1058,7 @@ var SceneManager = new Class({ { if (this._processing) { - this._queue.push( { op: 'moveUp', keyA: key, keyB: null }); + this._queue.push({ op: 'moveUp', keyA: key, keyB: null }); } else { @@ -1024,7 +1080,7 @@ var SceneManager = new Class({ queueOp: function (op, keyA, keyB) { - this._queue.push( { op: op, keyA: keyA, keyB: keyB }); + this._queue.push({ op: op, keyA: keyA, keyB: keyB }); return this; }, @@ -1049,7 +1105,7 @@ var SceneManager = new Class({ if (this._processing) { - this._queue.push( { op: 'swapPosition', keyA: keyA, keyB: keyB }); + this._queue.push({ op: 'swapPosition', keyA: keyA, keyB: keyB }); } else { diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 9057d2b2b..4dc859849 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -8,16 +8,39 @@ var Class = require('../utils/Class'); var CONST = require('./const'); var PluginManager = require('../plugins/PluginManager'); -// A proxy class to the Global Scene Manager +/** + * @classdesc + * A proxy class to the Global Scene Manager. + * + * @class ScenePlugin + * @memberOf Phaser.Scenes + * @constructor + * @since 3.0.0 + * + * @param {Phaser.Scene} scene - [description] + */ var ScenePlugin = new Class({ initialize: function ScenePlugin (scene) { - // The Scene that owns this plugin + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#scene + * @type {Phaser.Scene} + * @since 3.0.0 + */ this.scene = scene; + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#systems + * @type {Phaser.Scenes.Systems} + * @since 3.0.0 + */ this.systems = scene.sys; if (!scene.sys.settings.isBooted) @@ -25,17 +48,50 @@ var ScenePlugin = new Class({ scene.sys.events.once('boot', this.boot, this); } + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#settings + * @type {object} + * @since 3.0.0 + */ this.settings = scene.sys.settings; + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#key + * @type {string} + * @since 3.0.0 + */ this.key = scene.sys.settings.key; - // SceneManager + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#manager + * @type {Phaser.Scenes.SceneManager} + * @since 3.0.0 + */ this.manager = scene.sys.game.scene; - // Private + /** + * [description] + * + * @name Phaser.Scenes.ScenePlugin#_queue + * @type {array} + * @private + * @since 3.0.0 + */ this._queue = []; }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#boot + * @since 3.0.0 + */ boot: function () { var eventEmitter = this.systems.events; @@ -44,7 +100,17 @@ var ScenePlugin = new Class({ eventEmitter.on('destroy', this.destroy, this); }, - // Shutdown this Scene and run the given one + /** + * Shutdown this Scene and run the given one. + * + * @method Phaser.Scenes.ScenePlugin#start + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} [data] - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ start: function (key, data) { if (key === undefined) { key = this.key; } @@ -66,7 +132,18 @@ var ScenePlugin = new Class({ return this; }, - // Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set + /** + * Add the Scene into the Scene Manager and start it if 'autoStart' is true or the Scene config 'active' property is set. + * + * @method Phaser.Scenes.ScenePlugin#add + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} sceneConfig - [description] + * @param {boolean} autoStart - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ add: function (key, sceneConfig, autoStart) { this.manager.add(key, sceneConfig, autoStart); @@ -74,7 +151,17 @@ var ScenePlugin = new Class({ return this; }, - // Launch the given Scene and run it in parallel with this one + /** + * Launch the given Scene and run it in parallel with this one. + * + * @method Phaser.Scenes.ScenePlugin#launch + * @since 3.0.0 + * + * @param {string} key - [description] + * @param {object} [data] - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ launch: function (key, data) { if (key && key !== this.key) @@ -92,7 +179,16 @@ var ScenePlugin = new Class({ return this; }, - // Pause the Scene - this stops the update step from happening but it still renders + /** + * Pause the Scene - this stops the update step from happening but it still renders. + * + * @method Phaser.Scenes.ScenePlugin#pause + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ pause: function (key) { if (key === undefined) { key = this.key; } @@ -102,7 +198,16 @@ var ScenePlugin = new Class({ return this; }, - // Resume the Scene - starts the update loop again + /** + * Resume the Scene - starts the update loop again. + * + * @method Phaser.Scenes.ScenePlugin#resume + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ resume: function (key) { if (key === undefined) { key = this.key; } @@ -112,7 +217,16 @@ var ScenePlugin = new Class({ return this; }, - // Makes the Scene sleep (no update, no render) but doesn't shutdown + /** + * Makes the Scene sleep (no update, no render) but doesn't shutdown. + * + * @method Phaser.Scenes.ScenePlugin#sleep + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ sleep: function (key) { if (key === undefined) { key = this.key; } @@ -122,7 +236,16 @@ var ScenePlugin = new Class({ return this; }, - // Makes the Scene wake-up (starts update and render) + /** + * Makes the Scene wake-up (starts update and render) + * + * @method Phaser.Scenes.ScenePlugin#wake + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ wake: function (key) { if (key === undefined) { key = this.key; } @@ -132,7 +255,16 @@ var ScenePlugin = new Class({ return this; }, - // Makes this Scene sleep then starts the Scene given + /** + * Makes this Scene sleep then starts the Scene given. + * + * @method Phaser.Scenes.ScenePlugin#switch + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ switch: function (key) { if (key !== this.key) @@ -150,7 +282,16 @@ var ScenePlugin = new Class({ return this; }, - // Shutdown the Scene, clearing display list, timers, etc + /** + * Shutdown the Scene, clearing display list, timers, etc. + * + * @method Phaser.Scenes.ScenePlugin#stop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ stop: function (key) { if (key === undefined) { key = this.key; } @@ -160,6 +301,16 @@ var ScenePlugin = new Class({ return this; }, + /** + * Sets the active state of the given Scene. + * + * @method Phaser.Scenes.ScenePlugin#setActive + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ setActive: function (value) { this.settings.active = value; @@ -167,6 +318,16 @@ var ScenePlugin = new Class({ return this; }, + /** + * Sets the visible state of the given Scene. + * + * @method Phaser.Scenes.ScenePlugin#setVisible + * @since 3.0.0 + * + * @param {boolean} value - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ setVisible: function (value) { this.settings.visible = value; @@ -174,6 +335,16 @@ var ScenePlugin = new Class({ return this; }, + /** + * Checks if the given Scene is sleeping or not? + * + * @method Phaser.Scenes.ScenePlugin#isSleeping + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ isSleeping: function (key) { if (key === undefined) { key = this.key; } @@ -181,6 +352,16 @@ var ScenePlugin = new Class({ return this.manager.isSleeping(key); }, + /** + * Checks if the given Scene is active or not? + * + * @method Phaser.Scenes.ScenePlugin#isActive + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ isActive: function (key) { if (key === undefined) { key = this.key; } @@ -188,6 +369,16 @@ var ScenePlugin = new Class({ return this.manager.isActive(key); }, + /** + * Checks if the given Scene is visible or not? + * + * @method Phaser.Scenes.ScenePlugin#isVisible + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {boolean} [description] + */ isVisible: function (key) { if (key === undefined) { key = this.key; } @@ -195,6 +386,16 @@ var ScenePlugin = new Class({ return this.manager.isVisible(key); }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#swapPosition + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ swapPosition: function (key) { if (key && key !== this.key) @@ -205,6 +406,16 @@ var ScenePlugin = new Class({ return this; }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#moveUp + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ moveUp: function (key) { if (key === undefined) { key = this.key; } @@ -214,6 +425,16 @@ var ScenePlugin = new Class({ return this; }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#moveDown + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ moveDown: function (key) { if (key === undefined) { key = this.key; } @@ -223,6 +444,16 @@ var ScenePlugin = new Class({ return this; }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#bringToTop + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ bringToTop: function (key) { if (key === undefined) { key = this.key; } @@ -232,6 +463,16 @@ var ScenePlugin = new Class({ return this; }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#sendToBack + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scenes.ScenePlugin} This ScenePlugin object. + */ sendToBack: function (key) { if (key === undefined) { key = this.key; } @@ -241,16 +482,38 @@ var ScenePlugin = new Class({ return this; }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#get + * @since 3.0.0 + * + * @param {string} key - [description] + * + * @return {Phaser.Scene} [description] + */ get: function (key) { return this.manager.getScene(key); }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#shutdown + * @since 3.0.0 + */ shutdown: function () { // TODO }, + /** + * [description] + * + * @method Phaser.Scenes.ScenePlugin#destroy + * @since 3.0.0 + */ destroy: function () { // TODO