Adding docs.

This commit is contained in:
Richard Davey
2013-10-01 15:01:46 +01:00
parent fa15f8015d
commit 305b12d76b
64 changed files with 6268 additions and 2682 deletions
+89 -55
View File
@@ -1,56 +1,93 @@
/**
* Phaser - SoundManager
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2013 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
* @module Phaser.SoundManager
*/
/**
* Sound Manager constructor.
*
* @class SoundManager
* @class Phaser.SoundManager
* @classdesc Phaser Sound Manager.
* @constructor
* @param {Phaser.Game} game reference to the current game instance.
*/
Phaser.SoundManager = function (game) {
/**
* A reference to the currently running Game.
* @property game
* @public
* @type {Phaser.Game}
*/
/**
* @property {Phaser.Game} game - Local reference to game.
*/
this.game = game;
/**
* @property {Phaser.Signal} onSoundDecode - Description.
*/
this.onSoundDecode = new Phaser.Signal;
/**
* Boolean indicating whether the game is on "mute"
* @property _muted
* @private
* @type {bool}
*/
/**
* @property {bool} _muted - Description.
* @private
* @default
*/
this._muted = false;
/**
* @property {Description} _unlockSource - Description.
* @private
* @default
*/
this._unlockSource = null;
/**
* The global audio volume. A value between 0 (silence) and 1 (full volume)
* @property _volume
* @property {number} _volume - The global audio volume. A value between 0 (silence) and 1 (full volume).
* @private
* @type {number}
* @default
*/
this._volume = 1;
/**
* An array containing all the sounds
* @property _sounds
* @property {array} _sounds - An array containing all the sounds
* @private
* @type {array}
* @default The empty array.
*/
this._sounds = [];
/**
* @property {Description} context - Description.
* @default
*/
this.context = null;
/**
* @property {bool} usingWebAudio - Description.
* @default
*/
this.usingWebAudio = true;
/**
* @property {bool} usingAudioTag - Description.
* @default
*/
this.usingAudioTag = false;
/**
* @property {bool} noAudio - Description.
* @default
*/
this.noAudio = false;
/**
* @property {bool} touchLocked - Description.
* @default
*/
this.touchLocked = false;
/**
* @property {number} channels - Description.
* @default
*/
this.channels = 32;
};
@@ -58,7 +95,7 @@ Phaser.SoundManager = function (game) {
Phaser.SoundManager.prototype = {
/**
* Initialises the sound manager
* Initialises the sound manager.
* @method boot
*/
boot: function () {
@@ -140,7 +177,7 @@ Phaser.SoundManager.prototype = {
},
/**
* Enables the audio, usually after the first touch
* Enables the audio, usually after the first touch.
* @method unlock
*/
unlock: function () {
@@ -174,7 +211,7 @@ Phaser.SoundManager.prototype = {
},
/**
* Stops all the sounds in the game
* Stops all the sounds in the game.
* @method stopAll
*/
stopAll: function () {
@@ -190,7 +227,7 @@ Phaser.SoundManager.prototype = {
},
/**
* Pauses all the sounds in the game
* Pauses all the sounds in the game.
* @method pauseAll
*/
pauseAll: function () {
@@ -206,7 +243,7 @@ Phaser.SoundManager.prototype = {
},
/**
* resumes every sound in the game
* resumes every sound in the game.
* @method resumeAll
*/
resumeAll: function () {
@@ -224,8 +261,8 @@ Phaser.SoundManager.prototype = {
/**
* Decode a sound with its assets key.
* @method decode
* @param key {string} Assets key of the sound to be decoded.
* @param [sound] {Phaser.Sound} its bufer will be set to decoded data.
* @param {string} key - Assets key of the sound to be decoded.
* @param {Phaser.Sound} [sound] - Its buffer will be set to decoded data.
*/
decode: function (key, sound) {
@@ -254,7 +291,7 @@ Phaser.SoundManager.prototype = {
},
/**
* updates every sound in the game
* Updates every sound in the game.
* @method update
*/
update: function () {
@@ -282,17 +319,19 @@ Phaser.SoundManager.prototype = {
/**
*
* Description.
* @method add
* @param {string} key Asset key for the sound.
* @param {number} volume Default value for the volume.
* @param {bool} loop Whether or not the sound will loop.
* @param {string} key - Asset key for the sound.
* @param {number} volume - Default value for the volume.
* @param {bool} loop - Whether or not the sound will loop.
*/
add: function (key, volume, loop) {
volume = volume || 1;
if (typeof loop == 'undefined') { loop = false; }
var sound = new Phaser.Sound(this.game, key, volume, loop);
this._sounds.push(sound);
@@ -303,24 +342,21 @@ Phaser.SoundManager.prototype = {
};
/**
* A global audio mute toggle.
* @return {bool} Whether or not the game is on "mute".
*//**
* Mute sounds.
* @param {bool} value - Whether or not the game is on "mute"
*/
Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
/**
* A global audio mute toggle.
* @method mute
* @return {bool} whether or not the game is on "mute"
*/
get: function () {
return this._muted;
},
/**
* Mute sounds.
* @method mute
* @return {bool} whether or not the game is on "mute"
*/
set: function (value) {
value = value || null;
@@ -376,12 +412,15 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
});
/**
* Get
* @return {number} The global audio volume. A value between 0 (silence) and 1 (full volume).
*//**
* Sets the global volume
* @return {number} value - The global audio volume. A value between 0 (silence) and 1 (full volume).
*/
Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
/**
* @method volume
* @return {number} The global audio volume. A value between 0 (silence) and 1 (full volume)
*/
get: function () {
if (this.usingWebAudio)
@@ -395,11 +434,6 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
},
/**
* Sets the global volume
* @method volume
* @return {number} The global audio volume. A value between 0 (silence) and 1 (full volume)
*/
set: function (value) {
value = this.game.math.clamp(value, 1, 0);