Added jsdocs

This commit is contained in:
Richard Davey 2018-02-12 15:18:31 +00:00
parent eaca4eb462
commit fd9cf6c1f7
7 changed files with 372 additions and 8 deletions

View file

@ -55,7 +55,7 @@ var Game = new Class({
/**
* A reference to either the Canvas or WebGL Renderer that this Game is using.
*
* @property {Phaser.Renderer.CanvasRenderer|Phaser.Renderer.WebGLRenderer} renderer
* @property {Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer} renderer
* @since 3.0.0
*/
this.renderer = null;

View file

@ -1,6 +1,16 @@
var GetFastValue = require('../utils/object/GetFastValue');
var UppercaseFirst = require('../utils/string/UppercaseFirst');
/**
* Builds an array of which physics plugins should be activated for the given Scene.
*
* @function Phaser.Scenes.GetPhysicsPlugins
* @since 3.0.0
*
* @param {Phaser.Scenes.Systems} sys - [description]
*
* @return {array} [description]
*/
var GetPhysicsPlugins = function (sys)
{
var defaultSystem = sys.game.config.defaultPhysicsSystem;

View file

@ -1,5 +1,15 @@
var GetFastValue = require('../utils/object/GetFastValue');
/**
* Builds an array of which plugins (not including physics plugins) should be activated for the given Scene.
*
* @function Phaser.Scenes.GetScenePlugins
* @since 3.0.0
*
* @param {Phaser.Scenes.Systems} sys - [description]
*
* @return {array} [description]
*/
var GetScenePlugins = function (sys)
{
var defaultPlugins = sys.game.config.defaultPlugins;

View file

@ -1,17 +1,40 @@
var Class = require('../utils/Class');
var Systems = require('./Systems');
/**
* @classdesc
* [description]
*
* @class Scene
* @memberOf Phaser
* @constructor
* @since 3.0.0
*
* @param {object} config - [description]
*/
var Scene = new Class({
initialize:
function Scene (config)
{
// The Scene Systems. You must never overwrite this property, or all hell will break lose.
/**
* The Scene Systems. You must never overwrite this property, or all hell will break lose.
*
* @name Phaser.Scene#sys
* @type {Phaser.Scenes.Systems}
* @since 3.0.0
*/
this.sys = new Systems(this, config);
},
// Should be overridden by your own Scenes
/**
* Should be overridden by your own Scenes.
*
* @method Phaser.Scene#update
* @override
* @since 3.0.0
*/
update: function ()
{
}

View file

@ -2,6 +2,16 @@ var CONST = require('./const');
var GetValue = require('../utils/object/GetValue');
var InjectionMap = require('./InjectionMap');
/**
* Takes a Scene configuration object and returns a fully formed Systems object.
*
* @function Phaser.Scenes.Settings.create
* @since 3.0.0
*
* @param {object} config - [description]
*
* @return {object} [description]
*/
var Settings = {
create: function (config)

View file

@ -6,44 +6,212 @@ var GetScenePlugins = require('./GetScenePlugins');
var GlobalPlugins = require('../plugins/GlobalPlugins');
var Settings = require('./Settings');
/**
* @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 Systems
* @memberOf Phaser.Scenes
* @constructor
* @since 3.0.0
*
* @param {Phaser.Scene} scene - The Scene that owns this Systems instance.
* @param {object} config - Scene specific configuration settings.
*/
var Systems = new Class({
initialize:
function Systems (scene, config)
{
/**
* [description]
*
* @name Phaser.Scenes.Systems#scene
* @type {Phaser.Scene}
* @since 3.0.0
*/
this.scene = scene;
/**
* [description]
*
* @name Phaser.Scenes.Systems#game
* @type {Phaser.Game}
* @since 3.0.0
*/
this.game;
/**
* [description]
*
* @name Phaser.Scenes.Systems#config
* @type {object}
* @since 3.0.0
*/
this.config = config;
/**
* [description]
*
* @name Phaser.Scenes.Systems#settings
* @type {[type]}
* @since 3.0.0
*/
this.settings = Settings.create(config);
// A handy reference to the Scene canvas / context
/**
* A handy reference to the Scene canvas / context.
*
* @name Phaser.Scenes.Systems#canvas
* @type {HTMLCanvasElement}
* @since 3.0.0
*/
this.canvas;
/**
* [description]
*
* @name Phaser.Scenes.Systems#context
* @type {CanvasRenderingContext2D}
* @since 3.0.0
*/
this.context;
// Global Systems - these are single-instance global managers that belong to Game
/**
* [description]
*
* @name Phaser.Scenes.Systems#anims
* @type {Phaser.Animations.AnimationManager}
* @since 3.0.0
*/
this.anims;
/**
* [description]
*
* @name Phaser.Scenes.Systems#cache
* @type {Phaser.Cache.CacheManager}
* @since 3.0.0
*/
this.cache;
/**
* [description]
*
* @name Phaser.Scenes.Systems#plugins
* @type {Phaser.Plugins.PluginManager}
* @since 3.0.0
*/
this.plugins;
/**
* [description]
*
* @name Phaser.Scenes.Systems#registry
* @type {[type]}
* @since 3.0.0
*/
this.registry;
/**
* [description]
*
* @name Phaser.Scenes.Systems#sound
* @type {Phaser.Sound.BaseSoundManager}
* @since 3.0.0
*/
this.sound;
/**
* [description]
*
* @name Phaser.Scenes.Systems#textures
* @type {Phaser.Textures.TextureManager}
* @since 3.0.0
*/
this.textures;
// Core Plugins - these are non-optional Scene plugins, needed by lots of the other systems
/**
* [description]
*
* @name Phaser.Scenes.Systems#add
* @type {Phaser.GameObjects.GameObjectFactory}
* @since 3.0.0
*/
this.add;
/**
* [description]
*
* @name Phaser.Scenes.Systems#cameras
* @type {Phaser.Cameras.Scene2D.CameraManager}
* @since 3.0.0
*/
this.cameras;
/**
* [description]
*
* @name Phaser.Scenes.Systems#displayList
* @type {null}
* @since 3.0.0
*/
this.displayList;
/**
* [description]
*
* @name Phaser.Scenes.Systems#events
* @type {EventEmitter3}
* @since 3.0.0
*/
this.events;
/**
* [description]
*
* @name Phaser.Scenes.Systems#make
* @type {Phaser.GameObjects.GameObjectCreator}
* @since 3.0.0
*/
this.make;
/**
* [description]
*
* @name Phaser.Scenes.Systems#scenePlugin
* @type {Phaser.Scenes.ScenePlugin}
* @since 3.0.0
*/
this.scenePlugin;
/**
* [description]
*
* @name Phaser.Scenes.Systems#updateList
* @type {[type]}
* @since 3.0.0
*/
this.updateList;
},
/**
* [description]
*
* @method Phaser.Scenes.Systems#init
* @since 3.0.0
*
* @param {Phaser.Game} game - A reference to the Phaser Game
*/
init: function (game)
{
this.settings.status = CONST.INIT;
@ -70,6 +238,15 @@ var Systems = new Class({
this.settings.isBooted = true;
},
/**
* [description]
*
* @method Phaser.Scenes.Systems#install
* @private
* @since 3.0.0
*
* @param {array} plugin - An array of plugins to install into this Scene.
*/
install: function (plugin)
{
if (!Array.isArray(plugin))
@ -80,6 +257,15 @@ var Systems = new Class({
this.plugins.installLocal(this, plugin);
},
/**
* [description]
*
* @method Phaser.Scenes.Systems#step
* @since 3.0.0
*
* @param {number} time - [description]
* @param {number} delta - [description]
*/
step: function (time, delta)
{
this.events.emit('preupdate', time, delta);
@ -91,6 +277,14 @@ var Systems = new Class({
this.events.emit('postupdate', time, delta);
},
/**
* [description]
*
* @method Phaser.Scenes.Systems#render
* @since 3.0.0
*
* @param {Phaser.Renderer.Canvas.CanvasRenderer|Phaser.Renderer.WebGL.WebGLRenderer} renderer - [description]
*/
render: function (renderer)
{
var displayList = this.displayList;
@ -102,19 +296,37 @@ var Systems = new Class({
this.events.emit('render', renderer);
},
// Force a sort of the display list on the next render
/**
* Force a sort of the display list on the next render.
*
* @method Phaser.Scenes.Systems#queueDepthSort
* @since 3.0.0
*/
queueDepthSort: function ()
{
this.displayList.queueDepthSort();
},
// Immediately sorts the display list if the flag is set
/**
* Immediately sorts the display list if the flag is set.
*
* @method Phaser.Scenes.Systems#depthSort
* @since 3.0.0
*/
depthSort: function ()
{
this.displayList.depthSort();
},
// A paused Scene still renders, it just doesn't run ANY of its update handlers or systems
/**
* Pause this Scene.
* A paused Scene still renders, it just doesn't run ANY of its update handlers or systems.
*
* @method Phaser.Scenes.Systems#pause
* @since 3.0.0
*
* @return {Phaser.Scenes.Systems} This Systems object.
*/
pause: function ()
{
if (this.settings.active)
@ -125,8 +337,18 @@ var Systems = new Class({
this.events.emit('pause', this);
}
return this;
},
/**
* Resume this Scene.
*
* @method Phaser.Scenes.Systems#resume
* @since 3.0.0
*
* @return {Phaser.Scenes.Systems} This Systems object.
*/
resume: function ()
{
if (!this.settings.active)
@ -137,8 +359,21 @@ var Systems = new Class({
this.events.emit('resume', this);
}
return this;
},
/**
* Send this Scene to sleep.
*
* A sleeping Scene doesn't run it's update step or render anything, but it also isn't destroyed,
* or have any of its systems or children removed, meaning it can be re-activated at any point.
*
* @method Phaser.Scenes.Systems#sleep
* @since 3.0.0
*
* @return {Phaser.Scenes.Systems} This Systems object.
*/
sleep: function ()
{
this.settings.status = CONST.SLEEPING;
@ -147,8 +382,18 @@ var Systems = new Class({
this.settings.visible = false;
this.events.emit('sleep', this);
return this;
},
/**
* Wake-up this Scene if it was previously asleep.
*
* @method Phaser.Scenes.Systems#wake
* @since 3.0.0
*
* @return {Phaser.Scenes.Systems} This Systems object.
*/
wake: function ()
{
this.settings.status = CONST.RUNNING;
@ -157,23 +402,59 @@ var Systems = new Class({
this.settings.visible = true;
this.events.emit('wake', this);
return this;
},
/**
* Is this Scene sleeping?
*
* @method Phaser.Scenes.Systems#isSleeping
* @since 3.0.0
*
* @return {boolean} [description]
*/
isSleeping: function ()
{
return (this.settings.status === CONST.SLEEPING);
},
/**
* Is this Scene active?
*
* @method Phaser.Scenes.Systems#isActive
* @since 3.0.0
*
* @return {boolean} [description]
*/
isActive: function ()
{
return (this.settings.status === CONST.RUNNING);
},
/**
* Is this Scene visible and rendering?
*
* @method Phaser.Scenes.Systems#isVisible
* @since 3.0.0
*
* @return {boolean} [description]
*/
isVisible: function ()
{
return this.settings.visible;
},
/**
* [description]
*
* @method Phaser.Scenes.Systems#setVisible
* @since 3.0.0
*
* @param {boolean} value - [description]
*
* @return {Phaser.Scenes.Systems} This Systems object.
*/
setVisible: function (value)
{
this.settings.visible = value;
@ -181,6 +462,16 @@ var Systems = new Class({
return this;
},
/**
* [description]
*
* @method Phaser.Scenes.Systems#setActive
* @since 3.0.0
*
* @param {boolean} value - [description]
*
* @return {Phaser.Scenes.Systems} This Systems object.
*/
setActive: function (value)
{
if (value)
@ -193,6 +484,14 @@ var Systems = new Class({
}
},
/**
* Start this Scene running and rendering.
*
* @method Phaser.Scenes.Systems#start
* @since 3.0.0
*
* @param {object} data - [description]
*/
start: function (data)
{
this.settings.status = CONST.START;
@ -205,6 +504,12 @@ var Systems = new Class({
this.events.emit('start', this);
},
/**
* Shutdown this Scene and send a shutdown event to all of its systems.
*
* @method Phaser.Scenes.Systems#shutdown
* @since 3.0.0
*/
shutdown: function ()
{
this.settings.status = CONST.SHUTDOWN;
@ -215,6 +520,12 @@ var Systems = new Class({
this.events.emit('shutdown', this);
},
/**
* Destroy this Scene and send a destroy event all of its systems.
*
* @method Phaser.Scenes.Systems#destroy
* @since 3.0.0
*/
destroy: function ()
{
this.settings.status = CONST.DESTROYED;

View file

@ -9,7 +9,7 @@ var NOOP = require('../utils/NOOP');
* Not all browsers can play all audio formats.
* There is a good guide to what's supported [here](https://developer.mozilla.org/en-US/Apps/Fundamentals/Audio_and_video_delivery/Cross-browser_audio_basics#Audio_Codec_Support).
*
* @class BaseSound
* @class BaseSoundManager
* @extends Phaser.Sound.EventEmitter
* @memberOf Phaser.Sound
* @constructor