diff --git a/src/input/InputPlugin.js b/src/input/InputPlugin.js index 995209332..9643443fa 100644 --- a/src/input/InputPlugin.js +++ b/src/input/InputPlugin.js @@ -89,7 +89,7 @@ var InputPlugin = new Class({ * A reference to the Scene Systems Settings. * * @name Phaser.Input.InputPlugin#settings - * @type {Phaser.Scenes.Settings.Object} + * @type {Phaser.Scenes.Types.SettingsObject} * @since 3.5.0 */ this.settings = scene.sys.settings; diff --git a/src/input/gamepad/GamepadPlugin.js b/src/input/gamepad/GamepadPlugin.js index c80fd74ab..09653df89 100644 --- a/src/input/gamepad/GamepadPlugin.js +++ b/src/input/gamepad/GamepadPlugin.js @@ -78,7 +78,7 @@ var GamepadPlugin = new Class({ * A reference to the Scene Systems Settings. * * @name Phaser.Input.Gamepad.GamepadPlugin#settings - * @type {Phaser.Scenes.Settings.Object} + * @type {Phaser.Scenes.Types.SettingsObject} * @since 3.10.0 */ this.settings = this.scene.sys.settings; diff --git a/src/input/keyboard/KeyboardPlugin.js b/src/input/keyboard/KeyboardPlugin.js index 9030a4451..d017c4712 100644 --- a/src/input/keyboard/KeyboardPlugin.js +++ b/src/input/keyboard/KeyboardPlugin.js @@ -94,7 +94,7 @@ var KeyboardPlugin = new Class({ * A reference to the Scene Systems Settings. * * @name Phaser.Input.Keyboard.KeyboardPlugin#settings - * @type {Phaser.Scenes.Settings.Object} + * @type {Phaser.Scenes.Types.SettingsObject} * @since 3.10.0 */ this.settings = this.scene.sys.settings; diff --git a/src/scene/Scene.js b/src/scene/Scene.js index 074e6b9a6..5190d7583 100644 --- a/src/scene/Scene.js +++ b/src/scene/Scene.js @@ -16,7 +16,7 @@ var Systems = require('./Systems'); * @constructor * @since 3.0.0 * - * @param {(string|Phaser.Scenes.Settings.Config)} config - Scene specific configuration settings. + * @param {(string|Phaser.Scenes.Types.SettingsConfig)} config - Scene specific configuration settings. */ var Scene = new Class({ diff --git a/src/scene/SceneManager.js b/src/scene/SceneManager.js index abf31b25d..00995694b 100644 --- a/src/scene/SceneManager.js +++ b/src/scene/SceneManager.js @@ -312,7 +312,7 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - A unique key used to reference the Scene, i.e. `MainMenu` or `Level1`. - * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The config for the Scene + * @param {(Phaser.Scene|Phaser.Scenes.Types.SettingsConfig|function)} sceneConfig - The config for the Scene * @param {boolean} [autoStart=false] - If `true` the Scene will be started immediately after being added. * @param {object} [data] - Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`. * @@ -706,7 +706,7 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The key of the Scene. - * @param {(string|Phaser.Scenes.Settings.Config)} sceneConfig - The Scene config. + * @param {(string|Phaser.Scenes.Types.SettingsConfig)} sceneConfig - The Scene config. * * @return {Phaser.Scene} The created Scene. */ @@ -784,7 +784,7 @@ var SceneManager = new Class({ * @since 3.0.0 * * @param {string} key - The key to check in the Scene config. - * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The Scene config. + * @param {(Phaser.Scene|Phaser.Scenes.Types.SettingsConfig|function)} sceneConfig - The Scene config. * * @return {string} The Scene key. */ diff --git a/src/scene/ScenePlugin.js b/src/scene/ScenePlugin.js index 377f053b3..d6edac323 100644 --- a/src/scene/ScenePlugin.js +++ b/src/scene/ScenePlugin.js @@ -49,7 +49,7 @@ var ScenePlugin = new Class({ * The settings of the Scene this ScenePlugin belongs to. * * @name Phaser.Scenes.ScenePlugin#settings - * @type {Phaser.Scenes.Settings.Object} + * @type {Phaser.Scenes.Types.SettingsObject} * @since 3.0.0 */ this.settings = scene.sys.settings; @@ -226,20 +226,6 @@ var ScenePlugin = new Class({ return this; }, - /** - * @typedef {object} SceneTransitionConfig - * - * @property {string} target - The Scene key to transition to. - * @property {integer} [duration=1000] - The duration, in ms, for the transition to last. - * @property {boolean} [sleep=false] - Will the Scene responsible for the transition be sent to sleep on completion (`true`), or stopped? (`false`) - * @property {boolean} [allowInput=false] - Will the Scenes Input system be able to process events while it is transitioning in or out? - * @property {boolean} [moveAbove] - Move the target Scene to be above this one before the transition starts. - * @property {boolean} [moveBelow] - Move the target Scene to be below this one before the transition starts. - * @property {function} [onUpdate] - This callback is invoked every frame for the duration of the transition. - * @property {any} [onUpdateScope] - The context in which the callback is invoked. - * @property {any} [data] - An object containing any data you wish to be passed to the target Scenes init / create methods. - */ - /** * This will start a transition from the current Scene to the target Scene given. * @@ -274,7 +260,7 @@ var ScenePlugin = new Class({ * @fires Phaser.Scenes.Events#TRANSITION_OUT * @since 3.5.0 * - * @param {SceneTransitionConfig} config - The transition configuration object. + * @param {Phaser.Scenes.Types.SceneTransitionConfig} config - The transition configuration object. * * @return {boolean} `true` is the transition was started, otherwise `false`. */ @@ -444,7 +430,7 @@ var ScenePlugin = new Class({ * @since 3.0.0 * * @param {string} key - The Scene key. - * @param {(Phaser.Scene|Phaser.Scenes.Settings.Config|function)} sceneConfig - The config for the Scene. + * @param {(Phaser.Scene|Phaser.Scenes.Types.SettingsConfig|function)} sceneConfig - The config for the Scene. * @param {boolean} autoStart - Whether to start the Scene after it's added. * @param {object} [data] - Optional data object. This will be set as Scene.settings.data and passed to `Scene.init`. * diff --git a/src/scene/Settings.js b/src/scene/Settings.js index 763fd1082..228c9af37 100644 --- a/src/scene/Settings.js +++ b/src/scene/Settings.js @@ -13,42 +13,6 @@ var InjectionMap = require('./InjectionMap'); * @namespace Phaser.Scenes.Settings */ -/** - * @typedef {object} Phaser.Scenes.Settings.Config - * - * @property {string} [key] - The unique key of this Scene. Must be unique within the entire Game instance. - * @property {boolean} [active=false] - Does the Scene start as active or not? An active Scene updates each step. - * @property {boolean} [visible=true] - Does the Scene start as visible or not? A visible Scene renders each step. - * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} [pack=false] - An optional Loader Packfile to be loaded before the Scene begins. - * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - An optional Camera configuration object. - * @property {Object.} [map] - Overwrites the default injection map for a scene. - * @property {Object.} [mapAdd] - Extends the injection map for a scene. - * @property {object} [physics={}] - The physics configuration object for the Scene. - * @property {object} [loader={}] - The loader configuration object for the Scene. - * @property {(false|*)} [plugins=false] - The plugin configuration object for the Scene. - */ - -/** - * @typedef {object} Phaser.Scenes.Settings.Object - * - * @property {number} status - The current status of the Scene. Maps to the Scene constants. - * @property {string} key - The unique key of this Scene. Unique within the entire Game instance. - * @property {boolean} active - The active state of this Scene. An active Scene updates each step. - * @property {boolean} visible - The visible state of this Scene. A visible Scene renders each step. - * @property {boolean} isBooted - Has the Scene finished booting? - * @property {boolean} isTransition - Is the Scene in a state of transition? - * @property {?Phaser.Scene} transitionFrom - The Scene this Scene is transitioning from, if set. - * @property {integer} transitionDuration - The duration of the transition, if set. - * @property {boolean} transitionAllowInput - Is this Scene allowed to receive input during transitions? - * @property {object} data - a data bundle passed to this Scene from the Scene Manager. - * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} pack - The Loader Packfile to be loaded before the Scene begins. - * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} cameras - The Camera configuration object. - * @property {Object.} map - The Scene's Injection Map. - * @property {object} physics - The physics configuration object for the Scene. - * @property {object} loader - The loader configuration object for the Scene. - * @property {(false|*)} plugins - The plugin configuration object for the Scene. - */ - var Settings = { /** @@ -57,9 +21,9 @@ var Settings = { * @function Phaser.Scenes.Settings.create * @since 3.0.0 * - * @param {(string|Phaser.Scenes.Settings.Config)} config - The Scene configuration object used to create this Scene Settings. + * @param {(string|Phaser.Scenes.Types.SettingsConfig)} config - The Scene configuration object used to create this Scene Settings. * - * @return {Phaser.Scenes.Settings.Object} The Scene Settings object created as a result of the config and default settings. + * @return {Phaser.Scenes.Types.SettingsObject} The Scene Settings object created as a result of the config and default settings. */ create: function (config) { diff --git a/src/scene/Systems.js b/src/scene/Systems.js index 80621d746..22a30d8a0 100644 --- a/src/scene/Systems.js +++ b/src/scene/Systems.js @@ -27,7 +27,7 @@ var Settings = require('./Settings'); * @since 3.0.0 * * @param {Phaser.Scene} scene - The Scene that owns this Systems instance. - * @param {(string|Phaser.Scenes.Settings.Config)} config - Scene specific configuration settings. + * @param {(string|Phaser.Scenes.Types.SettingsConfig)} config - Scene specific configuration settings. */ var Systems = new Class({ @@ -69,7 +69,7 @@ var Systems = new Class({ * The Scene Configuration object, as passed in when creating the Scene. * * @name Phaser.Scenes.Systems#config - * @type {(string|Phaser.Scenes.Settings.Config)} + * @type {(string|Phaser.Scenes.Types.SettingsConfig)} * @since 3.0.0 */ this.config = config; @@ -78,7 +78,7 @@ var Systems = new Class({ * The Scene Settings. This is the parsed output based on the Scene configuration. * * @name Phaser.Scenes.Systems#settings - * @type {Phaser.Scenes.Settings.Object} + * @type {Phaser.Scenes.Types.SettingsObject} * @since 3.0.0 */ this.settings = Settings.create(config); diff --git a/src/scene/typedefs/SceneTransitionConfig.js b/src/scene/typedefs/SceneTransitionConfig.js new file mode 100644 index 000000000..ac648839d --- /dev/null +++ b/src/scene/typedefs/SceneTransitionConfig.js @@ -0,0 +1,14 @@ +/** + * @typedef {object} Phaser.Scenes.Types.SceneTransitionConfig + * @since 3.5.0 + * + * @property {string} target - The Scene key to transition to. + * @property {integer} [duration=1000] - The duration, in ms, for the transition to last. + * @property {boolean} [sleep=false] - Will the Scene responsible for the transition be sent to sleep on completion (`true`), or stopped? (`false`) + * @property {boolean} [allowInput=false] - Will the Scenes Input system be able to process events while it is transitioning in or out? + * @property {boolean} [moveAbove] - Move the target Scene to be above this one before the transition starts. + * @property {boolean} [moveBelow] - Move the target Scene to be below this one before the transition starts. + * @property {function} [onUpdate] - This callback is invoked every frame for the duration of the transition. + * @property {any} [onUpdateScope] - The context in which the callback is invoked. + * @property {any} [data] - An object containing any data you wish to be passed to the target Scenes init / create methods. + */ diff --git a/src/scene/typedefs/SettingsConfig.js b/src/scene/typedefs/SettingsConfig.js new file mode 100644 index 000000000..8ef97df96 --- /dev/null +++ b/src/scene/typedefs/SettingsConfig.js @@ -0,0 +1,15 @@ +/** + * @typedef {object} Phaser.Scenes.Types.SettingsConfig + * @since 3.0.0 + * + * @property {string} [key] - The unique key of this Scene. Must be unique within the entire Game instance. + * @property {boolean} [active=false] - Does the Scene start as active or not? An active Scene updates each step. + * @property {boolean} [visible=true] - Does the Scene start as visible or not? A visible Scene renders each step. + * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} [pack=false] - An optional Loader Packfile to be loaded before the Scene begins. + * @property {?(InputJSONCameraObject|InputJSONCameraObject[])} [cameras=null] - An optional Camera configuration object. + * @property {Object.} [map] - Overwrites the default injection map for a scene. + * @property {Object.} [mapAdd] - Extends the injection map for a scene. + * @property {object} [physics={}] - The physics configuration object for the Scene. + * @property {object} [loader={}] - The loader configuration object for the Scene. + * @property {(false|*)} [plugins=false] - The plugin configuration object for the Scene. + */ diff --git a/src/scene/typedefs/SettingsObject.js b/src/scene/typedefs/SettingsObject.js new file mode 100644 index 000000000..b0d732d77 --- /dev/null +++ b/src/scene/typedefs/SettingsObject.js @@ -0,0 +1,21 @@ +/** + * @typedef {object} Phaser.Scenes.Types.SettingsObject + * @since 3.0.0 + * + * @property {number} status - The current status of the Scene. Maps to the Scene constants. + * @property {string} key - The unique key of this Scene. Unique within the entire Game instance. + * @property {boolean} active - The active state of this Scene. An active Scene updates each step. + * @property {boolean} visible - The visible state of this Scene. A visible Scene renders each step. + * @property {boolean} isBooted - Has the Scene finished booting? + * @property {boolean} isTransition - Is the Scene in a state of transition? + * @property {?Phaser.Scene} transitionFrom - The Scene this Scene is transitioning from, if set. + * @property {integer} transitionDuration - The duration of the transition, if set. + * @property {boolean} transitionAllowInput - Is this Scene allowed to receive input during transitions? + * @property {object} data - a data bundle passed to this Scene from the Scene Manager. + * @property {(false|Phaser.Loader.FileTypes.PackFileConfig)} pack - The Loader Packfile to be loaded before the Scene begins. + * @property {?(Phaser.Cameras.Scene2D.Types.JSONCamera|Phaser.Cameras.Scene2D.Types.JSONCamera[])} cameras - The Camera configuration object. + * @property {Object.} map - The Scene's Injection Map. + * @property {object} physics - The physics configuration object for the Scene. + * @property {object} loader - The loader configuration object for the Scene. + * @property {(false|*)} plugins - The plugin configuration object for the Scene. + */ diff --git a/src/scene/typedefs/index.js b/src/scene/typedefs/index.js new file mode 100644 index 000000000..6ffe87ea3 --- /dev/null +++ b/src/scene/typedefs/index.js @@ -0,0 +1,9 @@ +/** + * @author Richard Davey + * @copyright 2019 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Scenes.Types + */ diff --git a/src/sound/BaseSound.js b/src/sound/BaseSound.js index b64d103a0..649ada449 100644 --- a/src/sound/BaseSound.js +++ b/src/sound/BaseSound.js @@ -23,7 +23,7 @@ var NOOP = require('../utils/NOOP'); * * @param {Phaser.Sound.BaseSoundManager} manager - Reference to the current sound manager instance. * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config] - An optional config object containing default sound settings. */ var BaseSound = new Class({ @@ -116,7 +116,7 @@ var BaseSound = new Class({ * Default values will be set by properties' setters. * * @name Phaser.Sound.BaseSound#config - * @type {SoundConfig} + * @type {Phaser.Sound.Types.SoundConfig} * @private * @since 3.0.0 */ @@ -137,7 +137,7 @@ var BaseSound = new Class({ * It could be default config or marker config. * * @name Phaser.Sound.BaseSound#currentConfig - * @type {SoundConfig} + * @type {Phaser.Sound.Types.SoundConfig} * @private * @since 3.0.0 */ @@ -149,7 +149,7 @@ var BaseSound = new Class({ * Object containing markers definitions. * * @name Phaser.Sound.BaseSound#markers - * @type {Object.} + * @type {Object.} * @default {} * @readonly * @since 3.0.0 @@ -161,7 +161,7 @@ var BaseSound = new Class({ * 'null' if whole sound is playing. * * @name Phaser.Sound.BaseSound#currentMarker - * @type {SoundMarker} + * @type {Phaser.Sound.Types.SoundMarker} * @default null * @readonly * @since 3.0.0 @@ -232,7 +232,7 @@ var BaseSound = new Class({ * @method Phaser.Sound.BaseSound#updateMarker * @since 3.0.0 * - * @param {SoundMarker} marker - Marker object with updated values. + * @param {Phaser.Sound.Types.SoundMarker} marker - Marker object with updated values. * * @return {boolean} Whether the marker was updated successfully. */ @@ -264,7 +264,7 @@ var BaseSound = new Class({ * * @param {string} markerName - The name of the marker to remove. * - * @return {?SoundMarker} Removed marker object or 'null' if there was no marker with provided name. + * @return {?Phaser.Sound.Types.SoundMarker} Removed marker object or 'null' if there was no marker with provided name. */ removeMarker: function (markerName) { @@ -289,7 +289,7 @@ var BaseSound = new Class({ * @since 3.0.0 * * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * @param {Phaser.Sound.Types.SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. * * @return {boolean} Whether the sound started playing successfully. */ diff --git a/src/sound/BaseSoundManager.js b/src/sound/BaseSoundManager.js index 744ee95f3..e6fff1ff6 100644 --- a/src/sound/BaseSoundManager.js +++ b/src/sound/BaseSoundManager.js @@ -12,23 +12,6 @@ var Events = require('./events'); var GameEvents = require('../core/events'); var NOOP = require('../utils/NOOP'); -/** - * @callback EachActiveSoundCallback - * - * @param {Phaser.Sound.BaseSoundManager} manager - The SoundManager - * @param {Phaser.Sound.BaseSound} sound - The current active Sound - * @param {number} index - The index of the current active Sound - * @param {Phaser.Sound.BaseSound[]} sounds - All sounds - */ - -/** - * Audio sprite sound type. - * - * @typedef {object} AudioSpriteSound - * - * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. - */ - /** * @classdesc * The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback. @@ -192,7 +175,7 @@ var BaseSoundManager = new Class({ * @since 3.0.0 * * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config] - An optional config object containing default sound settings. * * @return {Phaser.Sound.BaseSound} The new sound instance. */ @@ -207,9 +190,9 @@ var BaseSoundManager = new Class({ * @since 3.0.0 * * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config] - An optional config object containing default sound settings. * - * @return {AudioSpriteSound} The new audio sprite sound instance. + * @return {Phaser.Sound.Types.AudioSpriteSound} The new audio sprite sound instance. */ addAudioSprite: function (key, config) { @@ -252,7 +235,7 @@ var BaseSoundManager = new Class({ * @since 3.0.0 * * @param {string} key - Asset key for the sound. - * @param {(SoundConfig|SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. + * @param {(Phaser.Sound.Types.SoundConfig|Phaser.Sound.Types.SoundMarker)} [extra] - An optional additional object containing settings to be applied to the sound. It could be either config or marker object. * * @return {boolean} Whether the sound started playing successfully. */ @@ -291,7 +274,7 @@ var BaseSoundManager = new Class({ * * @param {string} key - Asset key for the sound. * @param {string} spriteName - The name of the sound sprite to play. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config] - An optional config object containing default sound settings. * * @return {boolean} Whether the audio sprite sound started playing successfully. */ @@ -513,7 +496,7 @@ var BaseSoundManager = new Class({ * @private * @since 3.0.0 * - * @param {EachActiveSoundCallback} callback - Callback function. (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Manager.BaseSound[]) => void + * @param {Phaser.Sound.Types.EachActiveSoundCallback} callback - Callback function. (manager: Phaser.Sound.BaseSoundManager, sound: Phaser.Sound.BaseSound, index: number, sounds: Phaser.Manager.BaseSound[]) => void * @param {*} [scope] - Callback context. */ forEachActiveSound: function (callback, scope) diff --git a/src/sound/html5/HTML5AudioSound.js b/src/sound/html5/HTML5AudioSound.js index 8470e6144..d85ba4145 100644 --- a/src/sound/html5/HTML5AudioSound.js +++ b/src/sound/html5/HTML5AudioSound.js @@ -21,7 +21,7 @@ var Events = require('../events'); * * @param {Phaser.Sound.HTML5AudioSoundManager} manager - Reference to the current sound manager instance. * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config={}] - An optional config object containing default sound settings. */ var HTML5AudioSound = new Class({ @@ -105,7 +105,7 @@ var HTML5AudioSound = new Class({ * @since 3.0.0 * * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * @param {Phaser.Sound.Types.SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. * * @return {boolean} Whether the sound started playing successfully. */ diff --git a/src/sound/html5/HTML5AudioSoundManager.js b/src/sound/html5/HTML5AudioSoundManager.js index a1606a129..a78725ed1 100644 --- a/src/sound/html5/HTML5AudioSoundManager.js +++ b/src/sound/html5/HTML5AudioSoundManager.js @@ -133,7 +133,7 @@ var HTML5AudioSoundManager = new Class({ * @since 3.0.0 * * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config] - An optional config object containing default sound settings. * * @return {Phaser.Sound.HTML5AudioSound} The new sound instance. */ diff --git a/src/sound/index.js b/src/sound/index.js index 112b3be5b..3d6bfcc11 100644 --- a/src/sound/index.js +++ b/src/sound/index.js @@ -9,31 +9,6 @@ * @namespace Phaser.Sound */ -/** - * Config object containing various sound settings. - * - * @typedef {object} SoundConfig - * - * @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not. - * @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume). - * @property {number} [rate=1] - Defines the speed at which the sound should be played. - * @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). - * @property {number} [seek=0] - Position of playback for this sound, in seconds. - * @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop. - * @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback. - */ - -/** - * Marked section of a sound represented by name, and optionally start time, duration, and config object. - * - * @typedef {object} SoundMarker - * - * @property {string} name - Unique identifier of a sound marker. - * @property {number} [start=0] - Sound position offset at witch playback should start. - * @property {number} [duration] - Playback duration of this marker. - * @property {SoundConfig} [config] - An optional config object containing default marker settings. - */ - module.exports = { SoundManagerCreator: require('./SoundManagerCreator'), diff --git a/src/sound/noaudio/NoAudioSound.js b/src/sound/noaudio/NoAudioSound.js index 14321b7e4..439b11152 100644 --- a/src/sound/noaudio/NoAudioSound.js +++ b/src/sound/noaudio/NoAudioSound.js @@ -27,7 +27,7 @@ var Extend = require('../../utils/object/Extend'); * * @param {Phaser.Sound.NoAudioSoundManager} manager - Reference to the current sound manager instance. * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config={}] - An optional config object containing default sound settings. */ var NoAudioSound = new Class({ diff --git a/src/sound/typedefs/AudioSpriteSound.js b/src/sound/typedefs/AudioSpriteSound.js new file mode 100644 index 000000000..fb6666880 --- /dev/null +++ b/src/sound/typedefs/AudioSpriteSound.js @@ -0,0 +1,8 @@ +/** + * Audio sprite sound type. + * + * @typedef {object} Phaser.Sound.Types.AudioSpriteSound + * @since 3.0.0 + * + * @property {object} spritemap - Local reference to 'spritemap' object form json file generated by audiosprite tool. + */ diff --git a/src/sound/typedefs/EachActiveSoundCallback.js b/src/sound/typedefs/EachActiveSoundCallback.js new file mode 100644 index 000000000..53bfd66fd --- /dev/null +++ b/src/sound/typedefs/EachActiveSoundCallback.js @@ -0,0 +1,9 @@ +/** + * @callback Phaser.Sound.Types.EachActiveSoundCallback + * @since 3.0.0 + * + * @param {Phaser.Sound.BaseSoundManager} manager - The SoundManager + * @param {Phaser.Sound.BaseSound} sound - The current active Sound + * @param {number} index - The index of the current active Sound + * @param {Phaser.Sound.BaseSound[]} sounds - All sounds + */ diff --git a/src/sound/typedefs/SoundConfig.js b/src/sound/typedefs/SoundConfig.js new file mode 100644 index 000000000..ee8823370 --- /dev/null +++ b/src/sound/typedefs/SoundConfig.js @@ -0,0 +1,14 @@ +/** + * Config object containing various sound settings. + * + * @typedef {object} Phaser.Sound.Types.SoundConfig + * @since 3.0.0 + * + * @property {boolean} [mute=false] - Boolean indicating whether the sound should be muted or not. + * @property {number} [volume=1] - A value between 0 (silence) and 1 (full volume). + * @property {number} [rate=1] - Defines the speed at which the sound should be played. + * @property {number} [detune=0] - Represents detuning of sound in [cents](https://en.wikipedia.org/wiki/Cent_%28music%29). + * @property {number} [seek=0] - Position of playback for this sound, in seconds. + * @property {boolean} [loop=false] - Whether or not the sound or current sound marker should loop. + * @property {number} [delay=0] - Time, in seconds, that should elapse before the sound actually starts its playback. + */ diff --git a/src/sound/typedefs/SoundMarker.js b/src/sound/typedefs/SoundMarker.js new file mode 100644 index 000000000..94ffaadb1 --- /dev/null +++ b/src/sound/typedefs/SoundMarker.js @@ -0,0 +1,11 @@ +/** + * Marked section of a sound represented by name, and optionally start time, duration, and config object. + * + * @typedef {object} Phaser.Sound.Types.SoundMarker + * @since 3.0.0 + * + * @property {string} name - Unique identifier of a sound marker. + * @property {number} [start=0] - Sound position offset at witch playback should start. + * @property {number} [duration] - Playback duration of this marker. + * @property {Phaser.Sound.Types.SoundConfig} [config] - An optional config object containing default marker settings. + */ diff --git a/src/sound/typedefs/index.js b/src/sound/typedefs/index.js new file mode 100644 index 000000000..728eed3ac --- /dev/null +++ b/src/sound/typedefs/index.js @@ -0,0 +1,9 @@ +/** + * @author Richard Davey + * @copyright 2019 Photon Storm Ltd. + * @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License} + */ + +/** + * @namespace Phaser.Sound.Types + */ diff --git a/src/sound/webaudio/WebAudioSound.js b/src/sound/webaudio/WebAudioSound.js index 51f37b266..6d07186a4 100644 --- a/src/sound/webaudio/WebAudioSound.js +++ b/src/sound/webaudio/WebAudioSound.js @@ -21,7 +21,7 @@ var Events = require('../events'); * * @param {Phaser.Sound.WebAudioSoundManager} manager - Reference to the current sound manager instance. * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config={}] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config={}] - An optional config object containing default sound settings. */ var WebAudioSound = new Class({ @@ -187,7 +187,7 @@ var WebAudioSound = new Class({ * @since 3.0.0 * * @param {string} [markerName=''] - If you want to play a marker then provide the marker name here, otherwise omit it to play the full sound. - * @param {SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. + * @param {Phaser.Sound.Types.SoundConfig} [config] - Optional sound config object to be applied to this marker or entire sound if no marker name is provided. It gets memorized for future plays of current section of the sound. * * @return {boolean} Whether the sound started playing successfully. */ diff --git a/src/sound/webaudio/WebAudioSoundManager.js b/src/sound/webaudio/WebAudioSoundManager.js index 31a25c797..73b0b1b72 100644 --- a/src/sound/webaudio/WebAudioSoundManager.js +++ b/src/sound/webaudio/WebAudioSoundManager.js @@ -120,7 +120,7 @@ var WebAudioSoundManager = new Class({ * @since 3.0.0 * * @param {string} key - Asset key for the sound. - * @param {SoundConfig} [config] - An optional config object containing default sound settings. + * @param {Phaser.Sound.Types.SoundConfig} [config] - An optional config object containing default sound settings. * * @return {Phaser.Sound.WebAudioSound} The new sound instance. */