From b806d66e0d7a469324fc56f211389ed45a472077 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 14:04:21 +0100 Subject: [PATCH 01/56] Dispatching seek event after the source has been updated --- v3/src/sound/webaudio/WebAudioSound.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/v3/src/sound/webaudio/WebAudioSound.js b/v3/src/sound/webaudio/WebAudioSound.js index b1d40b87b..dd344503a 100644 --- a/v3/src/sound/webaudio/WebAudioSound.js +++ b/v3/src/sound/webaudio/WebAudioSound.js @@ -491,12 +491,12 @@ Object.defineProperty(WebAudioSound.prototype, 'seek', { if (this.isPlaying || this.isPaused) { value = Math.min(Math.max(0, value), this.duration); this.currentConfig.seek = value; + if (this.isPlaying) { + this.stopAndRemoveBufferSource(); + this.createAndStartBufferSource(); + } this.events.dispatch(new SoundValueEvent(this, 'SOUND_SEEK', value)); } - if (this.isPlaying) { - this.stopAndRemoveBufferSource(); - this.createAndStartBufferSource(); - } } }); /** From a58b4020b5008e0b0ffa68d654ba95378554e110 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:11:15 +0100 Subject: [PATCH 02/56] Added HTML5AudioFile class for loading audio with html5 audio tag --- v3/src/loader/filetypes/HTML5AudioFile.js | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 v3/src/loader/filetypes/HTML5AudioFile.js diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js new file mode 100644 index 000000000..9ec4ad05d --- /dev/null +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -0,0 +1,28 @@ +var Class = require('../../utils/Class'); +var File = require('../File'); +var GetFastValue = require('../../utils/object/GetFastValue'); + +// Phaser.Loader.FileTypes.HTML5AudioFile + +var HTML5AudioFile = new Class({ + + Extends: File, + + initialize: + + function HTML5AudioFile (key, url, path, config) + { + var fileConfig = { + type: 'audio', + extension: GetFastValue(url, 'type', ''), + key: key, + url: GetFastValue(url, 'uri', url), + path: path, + config: config + }; + + File.call(this, fileConfig); + } +}); + +module.exports = HTML5AudioFile; From 96cc4337456a6344f63165e6d39fa1429c860640 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:16:15 +0100 Subject: [PATCH 03/56] Added load method to HTML5AudioFile class --- v3/src/loader/filetypes/HTML5AudioFile.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index 9ec4ad05d..a2677ab5b 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -1,6 +1,7 @@ var Class = require('../../utils/Class'); var File = require('../File'); var GetFastValue = require('../../utils/object/GetFastValue'); +var GetURL = require('../GetURL'); // Phaser.Loader.FileTypes.HTML5AudioFile @@ -22,7 +23,29 @@ var HTML5AudioFile = new Class({ }; File.call(this, fileConfig); + }, + + // Called by the Loader, starts the actual file downloading + load: function (callback, baseURL) + { + this.callback = callback; + + this.data = []; + + var instances = (this.config && this.config.instances) || 1; + + for(var i = 0; i < instances; i++) + { + var audio = new Audio(); + audio.name = this.key; + audio.preload = 'auto'; + audio.src = GetURL(this, baseURL || ''); + audio.load(); + + this.data.push(audio); } + } + }); module.exports = HTML5AudioFile; From 2d7e8c340331690780f7a536b5b8767e1d3f8cc1 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:17:46 +0100 Subject: [PATCH 04/56] Added onLoad and onError methods to HTML5AudioFile class --- v3/src/loader/filetypes/HTML5AudioFile.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index a2677ab5b..da91050b5 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -25,6 +25,16 @@ var HTML5AudioFile = new Class({ File.call(this, fileConfig); }, + onLoad: function () + { + this.callback(this, true); + }, + + onError: function (event) + { + this.callback(this, false); + }, + // Called by the Loader, starts the actual file downloading load: function (callback, baseURL) { From 881d37080b62ad621578b7c2f284271d1badc1b9 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:23:50 +0100 Subject: [PATCH 05/56] Adding and removing listeners for relevant events --- v3/src/loader/filetypes/HTML5AudioFile.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index da91050b5..f0d8492ac 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -35,6 +35,13 @@ var HTML5AudioFile = new Class({ this.callback(this, false); }, + onProgress: function (event) + { + var audio = event.target; + audio.removeEventListener('canplaythrough', this.onProgress); + audio.removeEventListener('error', this.onError); + }, + // Called by the Loader, starts the actual file downloading load: function (callback, baseURL) { @@ -49,6 +56,8 @@ var HTML5AudioFile = new Class({ var audio = new Audio(); audio.name = this.key; audio.preload = 'auto'; + audio.addEventListener('canplaythrough', this.onProgress, false); + audio.addEventListener('error', this.onProgress, false); audio.src = GetURL(this, baseURL || ''); audio.load(); From 2c89e628c8b5113084b77274126172046615bf4c Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:25:42 +0100 Subject: [PATCH 06/56] Added properties for keeping track of the loading progress --- v3/src/loader/filetypes/HTML5AudioFile.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index f0d8492ac..524aba036 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -40,6 +40,13 @@ var HTML5AudioFile = new Class({ var audio = event.target; audio.removeEventListener('canplaythrough', this.onProgress); audio.removeEventListener('error', this.onError); + + if(this.filesLoaded++ === this.filesTotal) + { + this.onLoad(); + } + + this.percentComplete = Math.min((this.filesLoaded / this.filesTotal), 1); }, // Called by the Loader, starts the actual file downloading @@ -51,6 +58,10 @@ var HTML5AudioFile = new Class({ var instances = (this.config && this.config.instances) || 1; + this.filesTotal = instances; + this.filesLoaded = 0; + this.percentComplete = 0; + for(var i = 0; i < instances; i++) { var audio = new Audio(); From 63e3159661f45df80a9d7358681e0ab47d329dc3 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:27:03 +0100 Subject: [PATCH 07/56] Incrementing filesLoaded before comparison --- v3/src/loader/filetypes/HTML5AudioFile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index 524aba036..ef4ac2f2e 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -41,7 +41,7 @@ var HTML5AudioFile = new Class({ audio.removeEventListener('canplaythrough', this.onProgress); audio.removeEventListener('error', this.onError); - if(this.filesLoaded++ === this.filesTotal) + if(++this.filesLoaded === this.filesTotal) { this.onLoad(); } From 60256888334e84d7fddbe81db7bc5b9c16280b9b Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:29:14 +0100 Subject: [PATCH 08/56] Setting event listeners directly as properties values to resolve scope issues --- v3/src/loader/filetypes/HTML5AudioFile.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index ef4ac2f2e..17d264101 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -38,8 +38,8 @@ var HTML5AudioFile = new Class({ onProgress: function (event) { var audio = event.target; - audio.removeEventListener('canplaythrough', this.onProgress); - audio.removeEventListener('error', this.onError); + audio.oncanplaythrough = null; + audio.onerror = null; if(++this.filesLoaded === this.filesTotal) { @@ -67,8 +67,8 @@ var HTML5AudioFile = new Class({ var audio = new Audio(); audio.name = this.key; audio.preload = 'auto'; - audio.addEventListener('canplaythrough', this.onProgress, false); - audio.addEventListener('error', this.onProgress, false); + audio.oncanplaythrough = this.onProgress.bind(this); + audio.onerror = this.onError.bind(this); audio.src = GetURL(this, baseURL || ''); audio.load(); From 95a348d634e2a938f67f695b4814fdb01ef533bc Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:30:49 +0100 Subject: [PATCH 09/56] Splitting audio objects initialization and loading to make sure all event listeners are set before any file starts loading --- v3/src/loader/filetypes/HTML5AudioFile.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index 17d264101..22a73d769 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -69,11 +69,16 @@ var HTML5AudioFile = new Class({ audio.preload = 'auto'; audio.oncanplaythrough = this.onProgress.bind(this); audio.onerror = this.onError.bind(this); - audio.src = GetURL(this, baseURL || ''); - audio.load(); this.data.push(audio); } + + for (i = 0; i < this.data.length; i++) + { + audio = this.data[i]; + audio.src = GetURL(this, baseURL || ''); + audio.load(); + } } }); From 2c8097f130ba708816c4f08a320f7abeec4a26a3 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:31:53 +0100 Subject: [PATCH 10/56] Clearing all events listeners if error occurs --- v3/src/loader/filetypes/HTML5AudioFile.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index 22a73d769..d4764fb3b 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -32,6 +32,13 @@ var HTML5AudioFile = new Class({ onError: function (event) { + for (var i = 0; i < this.data.length; i++) + { + var audio = this.data[i]; + audio.oncanplaythrough = null; + audio.onerror = null; + } + this.callback(this, false); }, From 51c8312b9547fe95eee7c8e9f69387e8390e7eaa Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:32:21 +0100 Subject: [PATCH 11/56] Added a TODO to handle iOS unlocking --- v3/src/loader/filetypes/HTML5AudioFile.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/v3/src/loader/filetypes/HTML5AudioFile.js index d4764fb3b..8c0751ce0 100644 --- a/v3/src/loader/filetypes/HTML5AudioFile.js +++ b/v3/src/loader/filetypes/HTML5AudioFile.js @@ -74,6 +74,9 @@ var HTML5AudioFile = new Class({ var audio = new Audio(); audio.name = this.key; audio.preload = 'auto'; + + // TODO check if ios is locked + audio.oncanplaythrough = this.onProgress.bind(this); audio.onerror = this.onError.bind(this); From fb9807ec4dad09d6cce9b55a09fc1be097e7dfcf Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:33:54 +0100 Subject: [PATCH 12/56] Returning HTML5AudioFile when certain conditions are met --- v3/src/loader/filetypes/AudioFile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v3/src/loader/filetypes/AudioFile.js b/v3/src/loader/filetypes/AudioFile.js index fdf2033c3..0f182ba35 100644 --- a/v3/src/loader/filetypes/AudioFile.js +++ b/v3/src/loader/filetypes/AudioFile.js @@ -2,6 +2,7 @@ var Class = require('../../utils/Class'); var File = require('../File'); var GetFastValue = require('../../utils/object/GetFastValue'); var CONST = require('../../const'); +var HTML5AudioFile = require('./HTML5AudioFile'); // Phaser.Loader.FileTypes.AudioFile @@ -85,8 +86,7 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings) return new AudioFile(key, url, loader.path, xhrSettings, game.sound.context); } - // TODO handle loading audio tags - return null; + return new HTML5AudioFile(key, url, loader.path, config); }; // this.load.audio('sound', 'assets/audio/booom.ogg', config, xhrSettings); From aa1d071c34dabfa975f4efcf7c3f5e6e5ab029f9 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:34:26 +0100 Subject: [PATCH 13/56] Resolved a TODO --- v3/src/loader/filetypes/AudioFile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/v3/src/loader/filetypes/AudioFile.js b/v3/src/loader/filetypes/AudioFile.js index 0f182ba35..f7079e4b5 100644 --- a/v3/src/loader/filetypes/AudioFile.js +++ b/v3/src/loader/filetypes/AudioFile.js @@ -67,7 +67,6 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings) if ((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) { - // TODO log not loading audio because sounds are disabled console.info('Skipping loading audio \'' + key + '\' since sounds are disabled.'); return null; } From ed86d8a58d8d2e4d990145dad3f9f9c0ee4050e3 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:34:35 +0100 Subject: [PATCH 14/56] Resolved a TODO --- v3/src/loader/filetypes/AudioFile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/v3/src/loader/filetypes/AudioFile.js b/v3/src/loader/filetypes/AudioFile.js index f7079e4b5..f97fef438 100644 --- a/v3/src/loader/filetypes/AudioFile.js +++ b/v3/src/loader/filetypes/AudioFile.js @@ -75,7 +75,6 @@ AudioFile.create = function (loader, key, urls, config, xhrSettings) if (!url) { - // TODO log no supported types console.warn('No supported url provided for audio \'' + key + '\'!'); return null; } From 9035c5e14e93bc7a5d99454482bd8ac61c38d85f Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:38:56 +0100 Subject: [PATCH 15/56] Preventing finishedLoading from being called multiple times --- v3/src/loader/BaseLoader.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/v3/src/loader/BaseLoader.js b/v3/src/loader/BaseLoader.js index ee86e65d9..ccf06ca71 100644 --- a/v3/src/loader/BaseLoader.js +++ b/v3/src/loader/BaseLoader.js @@ -194,6 +194,11 @@ var BaseLoader = new Class({ { // console.log('---> BaseLoader.finishedLoading PROCESSING', this.queue.size, 'files'); + if(this.state === CONST.LOADER_PROCESSING) + { + return; + } + this.state = CONST.LOADER_PROCESSING; this.storage.clear(); From 0cd1ec6819ecb251d421865a274300e6bcb93f00 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 17:39:46 +0100 Subject: [PATCH 16/56] Saving audio config value passed to game constructor --- v3/src/boot/Config.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/v3/src/boot/Config.js b/v3/src/boot/Config.js index 3fdce34d9..d02961058 100644 --- a/v3/src/boot/Config.js +++ b/v3/src/boot/Config.js @@ -13,7 +13,7 @@ var ValueToColor = require('../display/color/ValueToColor'); /** * @typedef {object} FPSConfig - * + * * @property {integer} [min=10] - [description] * @property {integer} [target=60] - [description] * @property {boolean} [forceSetTimeOut=false] - [description] @@ -25,7 +25,7 @@ var ValueToColor = require('../display/color/ValueToColor'); * @typedef {object} GameConfig * * @todo Add Physics Config - * + * * @property {integer|string} [width=1024] - [description] * @property {integer|string} [height=768] - [description] * @property {number} [zoom=1] - [description] @@ -81,7 +81,7 @@ var Config = new Class({ * @since 3.0.0 * * @param {object} [GameConfig] - The configuration object for your Phaser Game instance. - * + * */ function Config (config) { @@ -135,6 +135,8 @@ var Config = new Class({ this.disableContextMenu = GetValue(config, 'disableContextMenu', false); + this.audio = GetValue(config, 'audio'); + // If you do: { banner: false } it won't display any banner at all this.hideBanner = (GetValue(config, 'banner', null) === false); @@ -146,7 +148,7 @@ var Config = new Class({ { this.hideBanner = true; } - + // Frame Rate config // fps: { // min: 10, From 8972401e5de3b076ecafad0367b1a7bd70f1a096 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 18:06:36 +0100 Subject: [PATCH 17/56] Resolved a TODO --- v3/src/loader/filetypes/AudioFile.js | 1 - 1 file changed, 1 deletion(-) diff --git a/v3/src/loader/filetypes/AudioFile.js b/v3/src/loader/filetypes/AudioFile.js index f97fef438..4e1dd28bd 100644 --- a/v3/src/loader/filetypes/AudioFile.js +++ b/v3/src/loader/filetypes/AudioFile.js @@ -47,7 +47,6 @@ var AudioFile = new Class({ }, function (e) { - // TODO properly log decoding error console.error('Error with decoding audio data for \'' + this.key + '\':', e.message); _this.state = CONST.FILE_ERRORED; From 9a4022645282ed52013c6c4415a4d5cb1862e937 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 18:07:17 +0100 Subject: [PATCH 18/56] Printing audio implementation type in debug header --- v3/src/boot/DebugHeader.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/v3/src/boot/DebugHeader.js b/v3/src/boot/DebugHeader.js index 763af002f..eb7a45ceb 100644 --- a/v3/src/boot/DebugHeader.js +++ b/v3/src/boot/DebugHeader.js @@ -20,6 +20,24 @@ var DebugHeader = function (game) var renderType = (config.renderType === CONST.CANVAS) ? 'Canvas' : 'WebGL'; + var audioConfig = game.config.audio; + var deviceAudio = game.device.Audio; + + var audioType; + + if(deviceAudio.webAudio && !(audioConfig && audioConfig.disableWebAudio)) + { + audioType = 'Web Audio'; + } + else if((audioConfig && audioConfig.noAudio) || (!deviceAudio.webAudio && !deviceAudio.audioData)) + { + audioType = 'No Audio'; + } + else + { + audioType = 'HTML5 Audio'; + } + var ie = false; if (!ie) @@ -71,8 +89,7 @@ var DebugHeader = function (game) if (!config.hidePhaser) { - // TODO add audio - c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ')'); + c = c.concat('Phaser v' + CONST.VERSION + ' (' + renderType + ' | ' + audioType + ')'); } c = c.concat(' %c ' + config.gameURL); From a3d50f936d309abac875244258a9bda9f67e098a Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:21:55 +0100 Subject: [PATCH 19/56] Releasing references to sounds before releasing reference to sound array --- v3/src/sound/BaseSoundManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/BaseSoundManager.js b/v3/src/sound/BaseSoundManager.js index 4d4cd0509..1ea7dbe71 100644 --- a/v3/src/sound/BaseSoundManager.js +++ b/v3/src/sound/BaseSoundManager.js @@ -303,6 +303,7 @@ var BaseSoundManager = new Class({ this.forEachActiveSound(function (sound) { sound.destroy(); }); + this.sounds.length = 0; this.sounds = null; }, /** From 49e6b5129d39831f73e43ca434b76b6ba7cf62fb Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:22:34 +0100 Subject: [PATCH 20/56] No need for context reference, it is taken care of by forEachActiveSound method --- v3/src/sound/BaseSoundManager.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v3/src/sound/BaseSoundManager.js b/v3/src/sound/BaseSoundManager.js index 1ea7dbe71..81fc21214 100644 --- a/v3/src/sound/BaseSoundManager.js +++ b/v3/src/sound/BaseSoundManager.js @@ -337,7 +337,7 @@ Object.defineProperty(BaseSoundManager.prototype, 'rate', { this._rate = value; this.forEachActiveSound(function (sound) { sound.setRate(); - }, this); + }); this.events.dispatch(new SoundValueEvent(this, 'SOUND_RATE', value)); } }); @@ -355,7 +355,7 @@ Object.defineProperty(BaseSoundManager.prototype, 'detune', { this._detune = value; this.forEachActiveSound(function (sound) { sound.setRate(); - }, this); + }); this.events.dispatch(new SoundValueEvent(this, 'SOUND_DETUNE', value)); } }); From 526f6ae58ce5f87ed75da60210e4cebb6cb8bc84 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:23:11 +0100 Subject: [PATCH 21/56] Releasing references to rate updates objects before releasing reference to rateUpdates array --- v3/src/sound/webaudio/WebAudioSound.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/webaudio/WebAudioSound.js b/v3/src/sound/webaudio/WebAudioSound.js index dd344503a..44bb2331f 100644 --- a/v3/src/sound/webaudio/WebAudioSound.js +++ b/v3/src/sound/webaudio/WebAudioSound.js @@ -336,6 +336,7 @@ var WebAudioSound = new Class({ this.muteNode = null; this.volumeNode.disconnect(); this.volumeNode = null; + this.rateUpdates.length = 0; this.rateUpdates = null; }, /** From 171dac468a57ebc5b99fe2d02ef3d8034cd4e07d Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:25:11 +0100 Subject: [PATCH 22/56] Adding HTML5AudioSoundManager class that represents HTML5 Audio implementation of BaseSoundManager --- v3/src/sound/html5/HTML5AudioSoundManager.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 v3/src/sound/html5/HTML5AudioSoundManager.js diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js new file mode 100644 index 000000000..9a19e5851 --- /dev/null +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -0,0 +1,9 @@ +var Class = require('../../utils/Class'); +var BaseSoundManager = require('../BaseSoundManager'); +var HTML5AudioSoundManager = new Class({ + Extends: BaseSoundManager, + initialize: function HTML5AudioSoundManager(game) { + BaseSoundManager.call(this, game); + } +}); +module.exports = HTML5AudioSoundManager; From df450a4e170e6cb806c1b24f5aa383728d376c02 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:25:26 +0100 Subject: [PATCH 23/56] Adding HTML5AudioSoundManager class to index.js --- v3/src/sound/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/v3/src/sound/index.js b/v3/src/sound/index.js index 2dfa87786..1e6c599a0 100644 --- a/v3/src/sound/index.js +++ b/v3/src/sound/index.js @@ -10,6 +10,8 @@ module.exports = { WebAudioSound: require('./webaudio/WebAudioSound'), WebAudioSoundManager: require('./webaudio/WebAudioSoundManager'), + HTML5AudioSoundManager: require('./html5/HTML5AudioSoundManager'), + SoundEvent: require('./SoundEvent'), SoundValueEvent: require('./SoundValueEvent') }; From 197e370c7ba593a7b0236e37934c9134531a6ab3 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:26:32 +0100 Subject: [PATCH 24/56] Implemented add method for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 9a19e5851..3228f92c1 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -1,9 +1,15 @@ var Class = require('../../utils/Class'); var BaseSoundManager = require('../BaseSoundManager'); +var HTML5AudioSound = require('./HTML5AudioSound'); var HTML5AudioSoundManager = new Class({ Extends: BaseSoundManager, initialize: function HTML5AudioSoundManager(game) { BaseSoundManager.call(this, game); + }, + add: function (key, config) { + var sound = new HTML5AudioSound(this, key, config); + this.sounds.push(sound); + return sound; } }); module.exports = HTML5AudioSoundManager; From 8dc544667e67a28ec3e0d424fe2c67a8d3cea850 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:27:44 +0100 Subject: [PATCH 25/56] Initializing onBlurPausedSounds array used for keeping track of sounds paused when game looses focus --- v3/src/sound/html5/HTML5AudioSoundManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 3228f92c1..fc6311883 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -4,6 +4,7 @@ var HTML5AudioSound = require('./HTML5AudioSound'); var HTML5AudioSoundManager = new Class({ Extends: BaseSoundManager, initialize: function HTML5AudioSoundManager(game) { + this.onBlurPausedSounds = []; BaseSoundManager.call(this, game); }, add: function (key, config) { From 06bc5d62fcd03377be2ffe1f7a1e564511b6bcc7 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:28:21 +0100 Subject: [PATCH 26/56] Implemented onBlur method for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index fc6311883..1d3789270 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -11,6 +11,14 @@ var HTML5AudioSoundManager = new Class({ var sound = new HTML5AudioSound(this, key, config); this.sounds.push(sound); return sound; + }, + onBlur: function () { + this.forEachActiveSound(function (sound) { + if (sound.isPlaying) { + this.onBlurPausedSounds.push(sound); + sound.pause(); + } + }); } }); module.exports = HTML5AudioSoundManager; From 4d768c1c6ac6a3723c200e757ba104843818b1d5 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:29:01 +0100 Subject: [PATCH 27/56] Implemented onFocus method for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 1d3789270..3f477c596 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -19,6 +19,12 @@ var HTML5AudioSoundManager = new Class({ sound.pause(); } }); + }, + onFocus: function () { + this.onBlurPausedSounds.forEach(function (sound) { + sound.resume(); + }); + this.onBlurPausedSounds.length = 0; } }); module.exports = HTML5AudioSoundManager; From 5fcdca241b74158ee1adf36bb7c047d139ce21f6 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:29:16 +0100 Subject: [PATCH 28/56] Implemented destroy method for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 3f477c596..146b2596f 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -25,6 +25,11 @@ var HTML5AudioSoundManager = new Class({ sound.resume(); }); this.onBlurPausedSounds.length = 0; + }, + destroy: function () { + BaseSoundManager.prototype.destroy.call(this); + this.onBlurPausedSounds.length = 0; + this.onBlurPausedSounds = null; } }); module.exports = HTML5AudioSoundManager; From d3caa815d13872d1500d25f0c9e934f68a723cb5 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:30:42 +0100 Subject: [PATCH 29/56] Initializing _mute property used for storing global mute setting --- v3/src/sound/html5/HTML5AudioSoundManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 146b2596f..8d99506b4 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -5,6 +5,7 @@ var HTML5AudioSoundManager = new Class({ Extends: BaseSoundManager, initialize: function HTML5AudioSoundManager(game) { this.onBlurPausedSounds = []; + this._mute = false; BaseSoundManager.call(this, game); }, add: function (key, config) { From 86cccd53eed9e62bdd0e0bdc3290fcc350af93a5 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:31:26 +0100 Subject: [PATCH 30/56] Defining mute property for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 8d99506b4..5dd742118 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -33,4 +33,10 @@ var HTML5AudioSoundManager = new Class({ this.onBlurPausedSounds = null; } }); +Object.defineProperty(HTML5AudioSoundManager.prototype, 'mute', { + get: function () { + }, + set: function (value) { + } +}); module.exports = HTML5AudioSoundManager; From 8c5610416a42de4ae793236ca4b9b8430bdf65df Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:32:09 +0100 Subject: [PATCH 31/56] Implemented mute property getter for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 5dd742118..a87bcb7b3 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -35,6 +35,7 @@ var HTML5AudioSoundManager = new Class({ }); Object.defineProperty(HTML5AudioSoundManager.prototype, 'mute', { get: function () { + return this._mute; }, set: function (value) { } From fca5dcd1abbe586c969601779547b2a49fa1ba44 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:32:20 +0100 Subject: [PATCH 32/56] Implemented mute property setter for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index a87bcb7b3..d7491693c 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -38,6 +38,10 @@ Object.defineProperty(HTML5AudioSoundManager.prototype, 'mute', { return this._mute; }, set: function (value) { + this._mute = value; + this.forEachActiveSound(function (sound) { + sound.setMute(); + }); } }); module.exports = HTML5AudioSoundManager; From 1468febf74125333f77f17ee855522d3370c560c Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:32:41 +0100 Subject: [PATCH 33/56] Initializing _volume property used for storing global volume setting --- v3/src/sound/html5/HTML5AudioSoundManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index d7491693c..eec0842c1 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -6,6 +6,7 @@ var HTML5AudioSoundManager = new Class({ initialize: function HTML5AudioSoundManager(game) { this.onBlurPausedSounds = []; this._mute = false; + this._volume = 1; BaseSoundManager.call(this, game); }, add: function (key, config) { From 1521a8addc91acc0148fb6cf3237179d56268287 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:33:10 +0100 Subject: [PATCH 34/56] Defining volume property for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index eec0842c1..f31e1e757 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -45,4 +45,10 @@ Object.defineProperty(HTML5AudioSoundManager.prototype, 'mute', { }); } }); +Object.defineProperty(HTML5AudioSoundManager.prototype, 'volume', { + get: function () { + }, + set: function (value) { + } +}); module.exports = HTML5AudioSoundManager; From dd410e2e86aad7093454ff3b67182364a538b259 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:33:23 +0100 Subject: [PATCH 35/56] Implemented volume property getter for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index f31e1e757..9dd223076 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -47,6 +47,7 @@ Object.defineProperty(HTML5AudioSoundManager.prototype, 'mute', { }); Object.defineProperty(HTML5AudioSoundManager.prototype, 'volume', { get: function () { + return this._volume; }, set: function (value) { } From 5580ac923918c94e64e6260c9bce6ef7367994dc Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:33:43 +0100 Subject: [PATCH 36/56] Implemented volume property setter for HTML5AudioSoundManager class --- v3/src/sound/html5/HTML5AudioSoundManager.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 9dd223076..2065d23da 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -50,6 +50,10 @@ Object.defineProperty(HTML5AudioSoundManager.prototype, 'volume', { return this._volume; }, set: function (value) { + this._volume = value; + this.forEachActiveSound(function (sound) { + sound.setVolume(); + }); } }); module.exports = HTML5AudioSoundManager; From dbb4b18e22201379a946e5d0e06b336aac6769fb Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:34:23 +0100 Subject: [PATCH 37/56] Added onBlurPausedSounds property docs --- v3/src/sound/html5/HTML5AudioSoundManager.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index 2065d23da..f9e65f07a 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -4,6 +4,14 @@ var HTML5AudioSound = require('./HTML5AudioSound'); var HTML5AudioSoundManager = new Class({ Extends: BaseSoundManager, initialize: function HTML5AudioSoundManager(game) { + /** + * An array for keeping track of all the sounds + * that were paused when game lost focus. + * + * @private + * @property {Phaser.Sound.HTML5AudioSound[]} onBlurPausedSounds + * @default [] + */ this.onBlurPausedSounds = []; this._mute = false; this._volume = 1; From 1223bba62f7f3eee2e5b1e983e1929534918b6f0 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:34:41 +0100 Subject: [PATCH 38/56] Added _mute property docs --- v3/src/sound/html5/HTML5AudioSoundManager.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index f9e65f07a..a892c5eec 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -13,6 +13,14 @@ var HTML5AudioSoundManager = new Class({ * @default [] */ this.onBlurPausedSounds = []; + /** + * Property that actually holds the value of global mute + * for HTML5 Audio sound manager implementation. + * + * @private + * @property {boolean} _mute + * @default false + */ this._mute = false; this._volume = 1; BaseSoundManager.call(this, game); From 569b3950445d91277bf43c3bf36ea9ecd205926e Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:34:55 +0100 Subject: [PATCH 39/56] Added _volume property docs --- v3/src/sound/html5/HTML5AudioSoundManager.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index a892c5eec..c3267005f 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -22,6 +22,14 @@ var HTML5AudioSoundManager = new Class({ * @default false */ this._mute = false; + /** + * Property that actually holds the value of global volume + * for HTML5 Audio sound manager implementation. + * + * @private + * @property {boolean} _volume + * @default 1 + */ this._volume = 1; BaseSoundManager.call(this, game); }, From 4fb2959361ccccd98f9fa31f54de4dac206e9aea Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:35:13 +0100 Subject: [PATCH 40/56] Added mute property docs --- v3/src/sound/html5/HTML5AudioSoundManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index c3267005f..d50b9bd2a 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -58,6 +58,12 @@ var HTML5AudioSoundManager = new Class({ this.onBlurPausedSounds = null; } }); +/** + * Global mute setting. + * + * @name Phaser.Sound.HTML5AudioSoundManager#mute + * @property {boolean} mute + */ Object.defineProperty(HTML5AudioSoundManager.prototype, 'mute', { get: function () { return this._mute; From 8c41240cdead52d8cb83885b71c5878e414a1e04 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:35:29 +0100 Subject: [PATCH 41/56] Added volume property docs --- v3/src/sound/html5/HTML5AudioSoundManager.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/v3/src/sound/html5/HTML5AudioSoundManager.js index d50b9bd2a..cc68446f2 100644 --- a/v3/src/sound/html5/HTML5AudioSoundManager.js +++ b/v3/src/sound/html5/HTML5AudioSoundManager.js @@ -75,6 +75,12 @@ Object.defineProperty(HTML5AudioSoundManager.prototype, 'mute', { }); } }); +/** + * Global volume setting. + * + * @name Phaser.Sound.HTML5AudioSoundManager#volume + * @property {number} volume + */ Object.defineProperty(HTML5AudioSoundManager.prototype, 'volume', { get: function () { return this._volume; From 6909cbba49804db59b107be32e3228661ae30dfa Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:47:13 +0100 Subject: [PATCH 42/56] Adding HTML5AudioSound class that represents HTML5 Audio implementation of BaseSound --- v3/src/sound/html5/HTML5AudioSound.js | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 v3/src/sound/html5/HTML5AudioSound.js diff --git a/v3/src/sound/html5/HTML5AudioSound.js b/v3/src/sound/html5/HTML5AudioSound.js new file mode 100644 index 000000000..46643fb2d --- /dev/null +++ b/v3/src/sound/html5/HTML5AudioSound.js @@ -0,0 +1,10 @@ +var Class = require('../../utils/Class'); +var BaseSound = require('../BaseSound'); +var HTML5AudioSound = new Class({ + Extends: BaseSound, + initialize: function HTML5AudioSound(manager, key, config) { + if (config === void 0) { config = {}; } + BaseSound.call(this, manager, key, config); + } +}); +module.exports = HTML5AudioSound; From 2cdd6e1cfd76ea36705c3ab842a4c6fa1c43d3e7 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:47:59 +0100 Subject: [PATCH 43/56] Adding HTML5AudioSound class to index.js --- v3/src/sound/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/index.js b/v3/src/sound/index.js index 1e6c599a0..bc4cab78c 100644 --- a/v3/src/sound/index.js +++ b/v3/src/sound/index.js @@ -10,6 +10,7 @@ module.exports = { WebAudioSound: require('./webaudio/WebAudioSound'), WebAudioSoundManager: require('./webaudio/WebAudioSoundManager'), + HTML5AudioSound: require('./html5/HTML5AudioSound'), HTML5AudioSoundManager: require('./html5/HTML5AudioSoundManager'), SoundEvent: require('./SoundEvent'), From b0d0da6ecc455a40aa75d30bf2a96c9c8b229169 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:54:15 +0100 Subject: [PATCH 44/56] Initializing audio property --- v3/src/sound/html5/HTML5AudioSound.js | 1 + 1 file changed, 1 insertion(+) diff --git a/v3/src/sound/html5/HTML5AudioSound.js b/v3/src/sound/html5/HTML5AudioSound.js index 46643fb2d..50c3ea251 100644 --- a/v3/src/sound/html5/HTML5AudioSound.js +++ b/v3/src/sound/html5/HTML5AudioSound.js @@ -4,6 +4,7 @@ var HTML5AudioSound = new Class({ Extends: BaseSound, initialize: function HTML5AudioSound(manager, key, config) { if (config === void 0) { config = {}; } + this.audio = null; BaseSound.call(this, manager, key, config); } }); From e9040240f8d480e52918bb5dc021ea678d7eacc6 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Mon, 8 Jan 2018 19:54:40 +0100 Subject: [PATCH 45/56] Added audio property docs --- v3/src/sound/html5/HTML5AudioSound.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/v3/src/sound/html5/HTML5AudioSound.js b/v3/src/sound/html5/HTML5AudioSound.js index 50c3ea251..230ae9304 100644 --- a/v3/src/sound/html5/HTML5AudioSound.js +++ b/v3/src/sound/html5/HTML5AudioSound.js @@ -4,6 +4,13 @@ var HTML5AudioSound = new Class({ Extends: BaseSound, initialize: function HTML5AudioSound(manager, key, config) { if (config === void 0) { config = {}; } + /** + * Reference to HTML5 Audio tag used for playing sound. + * + * @private + * @property {HTMLAudioElement} audio + * @default null + */ this.audio = null; BaseSound.call(this, manager, key, config); } From 4fd10f437c6d08f22304bde7bf2b5df212655ef7 Mon Sep 17 00:00:00 2001 From: Hal Helms Date: Tue, 9 Jan 2018 21:58:13 -0800 Subject: [PATCH 46/56] Fix geom/point/Normalize.js --- src/geom/point/Normalize.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/geom/point/Normalize.js b/src/geom/point/Normalize.js index 196e96e3c..193ece471 100644 --- a/src/geom/point/Normalize.js +++ b/src/geom/point/Normalize.js @@ -12,7 +12,7 @@ var GetMagnitude = require('./GetMagnitude'); */ var Normalize = function (point) { - if (point.x !== 0 && point.y !== 0) + if (point.x !== 0 || point.y !== 0) { var m = GetMagnitude(point); From e128733f02ad68f85708e1ded8bce37a0a089d54 Mon Sep 17 00:00:00 2001 From: Hal Helms Date: Tue, 9 Jan 2018 22:05:34 -0800 Subject: [PATCH 47/56] Update WeightedRandomize() to support index arrays --- src/gameobjects/tilemap/components/WeightedRandomize.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gameobjects/tilemap/components/WeightedRandomize.js b/src/gameobjects/tilemap/components/WeightedRandomize.js index b786b0f40..3a9b31214 100644 --- a/src/gameobjects/tilemap/components/WeightedRandomize.js +++ b/src/gameobjects/tilemap/components/WeightedRandomize.js @@ -48,8 +48,10 @@ var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, sum += weightedIndexes[j].weight; if (rand <= sum) { - randomIndex = weightedIndexes[j].index; - break; + var chosen = weightedIndexes[j].index + randomIndex = Array.isArray(chosen) + ? chosen[Math.floor(Math.random() * chosen.length)] + : chosen } } From 302eba15d9260a96c7ad78f53cd0c4032f8124b7 Mon Sep 17 00:00:00 2001 From: Hal Helms Date: Tue, 9 Jan 2018 22:09:28 -0800 Subject: [PATCH 48/56] Update WeightedRandomize docs for index arrays --- src/gameobjects/tilemap/components/WeightedRandomize.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gameobjects/tilemap/components/WeightedRandomize.js b/src/gameobjects/tilemap/components/WeightedRandomize.js index 3a9b31214..74e34bd1e 100644 --- a/src/gameobjects/tilemap/components/WeightedRandomize.js +++ b/src/gameobjects/tilemap/components/WeightedRandomize.js @@ -20,7 +20,8 @@ var GetTilesWithin = require('./GetTilesWithin'); * @param {integer} [width=max width based on tileX] - [description] * @param {integer} [height=max height based on tileY] - [description] * @param {object[]} [weightedIndexes] - An array of objects to randomly draw from during - * randomization. They should be in the form: { index: 0, weight: 4 }. + * randomization. They should be in the form: { index: 0, weight: 4 } or + * { index: [0, 1], weight: 4 } if you wish to draw from multiple tile indexes. * @param {LayerData} layer - [description] */ var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, layer) From 42ad0ac399cef11507ea438613deeb463d4dfee1 Mon Sep 17 00:00:00 2001 From: Hal Helms Date: Tue, 9 Jan 2018 22:24:56 -0800 Subject: [PATCH 49/56] Add semicolons to WeightedRandomize --- src/gameobjects/tilemap/components/WeightedRandomize.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gameobjects/tilemap/components/WeightedRandomize.js b/src/gameobjects/tilemap/components/WeightedRandomize.js index 74e34bd1e..4a70a1af4 100644 --- a/src/gameobjects/tilemap/components/WeightedRandomize.js +++ b/src/gameobjects/tilemap/components/WeightedRandomize.js @@ -49,10 +49,10 @@ var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, sum += weightedIndexes[j].weight; if (rand <= sum) { - var chosen = weightedIndexes[j].index + var chosen = weightedIndexes[j].index; randomIndex = Array.isArray(chosen) ? chosen[Math.floor(Math.random() * chosen.length)] - : chosen + : chosen; } } From 89e4289c9d2bfa03eb2d7a1bbcf9bf96d264c467 Mon Sep 17 00:00:00 2001 From: Hal Helms Date: Tue, 9 Jan 2018 22:26:02 -0800 Subject: [PATCH 50/56] Fix WeightedRandomize.js --- src/gameobjects/tilemap/components/WeightedRandomize.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gameobjects/tilemap/components/WeightedRandomize.js b/src/gameobjects/tilemap/components/WeightedRandomize.js index 4a70a1af4..185109056 100644 --- a/src/gameobjects/tilemap/components/WeightedRandomize.js +++ b/src/gameobjects/tilemap/components/WeightedRandomize.js @@ -53,6 +53,7 @@ var WeightedRandomize = function (tileX, tileY, width, height, weightedIndexes, randomIndex = Array.isArray(chosen) ? chosen[Math.floor(Math.random() * chosen.length)] : chosen; + break; } } From 5d4bb532d66280dce79363f88fedb936be3349e1 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 10 Jan 2018 13:39:20 +0000 Subject: [PATCH 51/56] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 84 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..8fafdb309 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,84 @@ +# Code of Conduct + +## 1. Purpose + +A primary goal of Phaser is to be inclusive to the largest number of contributors, with the most varied and diverse backgrounds possible. As such, we are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, ability, ethnicity, socioeconomic status, and religion (or lack thereof). + +This code of conduct outlines our expectations for all those who participate in our community, as well as the consequences for unacceptable behavior. + +We invite all those who participate in Phaser to help us create safe and positive experiences for everyone. + +## 2. Open Source Citizenship + +A supplemental goal of this Code of Conduct is to increase open source citizenship by encouraging participants to recognize and strengthen the relationships between our actions and their effects on our community. + +Communities mirror the societies in which they exist and positive action is essential to counteract the many forms of inequality and abuses of power that exist in society. + +If you see someone who is making an extra effort to ensure our community is welcoming, friendly, and encourages all participants to contribute to the fullest extent, we want to know. + +## 3. Expected Behavior + +The following behaviors are expected and requested of all community members: + +* Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community. +* Exercise consideration and respect in your speech and actions. +* Attempt collaboration before conflict. +* Refrain from demeaning, discriminatory, or harassing behavior and speech. +* Be mindful of your surroundings and of your fellow participants. Alert community leaders if you notice a dangerous situation, someone in distress, or violations of this Code of Conduct, even if they seem inconsequential. +* Remember that community event venues may be shared with members of the public; please be respectful to all patrons of these locations. + +## 4. Unacceptable Behavior + +The following behaviors are considered harassment and are unacceptable within our community: + +* Violence, threats of violence or violent language directed against another person. +* Sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory jokes and language. +* Posting or displaying sexually explicit or violent material. +* Posting or threatening to post other people’s personally identifying information ("doxing"). +* Personal insults, particularly those related to gender, sexual orientation, race, religion, or disability. +* Inappropriate photography or recording. +* Inappropriate physical contact. You should have someone’s consent before touching them. +* Unwelcome sexual attention. This includes, sexualized comments or jokes; inappropriate touching, groping, and unwelcomed sexual advances. +* Deliberate intimidation, stalking or following (online or in person). +* Advocating for, or encouraging, any of the above behavior. +* Sustained disruption of community events, including talks and presentations. + +## 5. Consequences of Unacceptable Behavior + +Unacceptable behavior from any community member, including sponsors and those with decision-making authority, will not be tolerated. + +Anyone asked to stop unacceptable behavior is expected to comply immediately. + +If a community member engages in unacceptable behavior, the community organizers may take any action they deem appropriate, up to and including a temporary ban or permanent expulsion from the community without warning (and without refund in the case of a paid event). + +## 6. Reporting Guidelines + +If you are subject to or witness unacceptable behavior, or have any other concerns, please notify a community organizer as soon as possible. support@phaser.io. + + + +Additionally, community organizers are available to help community members engage with local law enforcement or to otherwise help those experiencing unacceptable behavior feel safe. In the context of in-person events, organizers will also provide escorts as desired by the person experiencing distress. + +## 7. Addressing Grievances + +If you feel you have been falsely or unfairly accused of violating this Code of Conduct, you should notify Photon Storm Ltd with a concise description of your grievance. Your grievance will be handled in accordance with our existing governing policies. + + + +## 8. Scope + +We expect all community participants (contributors, paid or otherwise; sponsors; and other guests) to abide by this Code of Conduct in all community venues–online and in-person–as well as in all one-on-one communications pertaining to community business. + +This code of conduct and its related procedures also applies to unacceptable behavior occurring outside the scope of community activities when such behavior has the potential to adversely affect the safety and well-being of community members. + +## 9. Contact info + +support@phaser.io + +## 10. License and attribution + +This Code of Conduct is distributed under a [Creative Commons Attribution-ShareAlike license](http://creativecommons.org/licenses/by-sa/3.0/). + +Portions of text derived from the [Django Code of Conduct](https://www.djangoproject.com/conduct/) and the [Geek Feminism Anti-Harassment Policy](http://geekfeminism.wikia.com/wiki/Conference_anti-harassment/Policy). + +Retrieved on November 22, 2016 from [http://citizencodeofconduct.org/](http://citizencodeofconduct.org/) From 59475c8fee62b0cab80094c877579b6a1c82e8b8 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 10 Jan 2018 13:43:06 +0000 Subject: [PATCH 52/56] Moved folder --- CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CODE_OF_CONDUCT.md => .github/CODE_OF_CONDUCT.md (100%) diff --git a/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT.md rename to .github/CODE_OF_CONDUCT.md From 0a10240c61d082ef6ed8d9d56edec5a628bb1fb8 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Wed, 10 Jan 2018 16:49:56 +0100 Subject: [PATCH 53/56] Moved HTML5AudioFile --- {v3/src => src}/loader/filetypes/HTML5AudioFile.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {v3/src => src}/loader/filetypes/HTML5AudioFile.js (100%) diff --git a/v3/src/loader/filetypes/HTML5AudioFile.js b/src/loader/filetypes/HTML5AudioFile.js similarity index 100% rename from v3/src/loader/filetypes/HTML5AudioFile.js rename to src/loader/filetypes/HTML5AudioFile.js From 081908fd7ba0d6bbac3aff1b47db03709e613bc9 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Wed, 10 Jan 2018 16:50:11 +0100 Subject: [PATCH 54/56] Moved HTML5AudioSound.js --- {v3/src => src}/sound/html5/HTML5AudioSound.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {v3/src => src}/sound/html5/HTML5AudioSound.js (100%) diff --git a/v3/src/sound/html5/HTML5AudioSound.js b/src/sound/html5/HTML5AudioSound.js similarity index 100% rename from v3/src/sound/html5/HTML5AudioSound.js rename to src/sound/html5/HTML5AudioSound.js From 9fc3aaa0da03b51c689dab3d241201ab889bbbf1 Mon Sep 17 00:00:00 2001 From: Pavle Goloskokovic Date: Wed, 10 Jan 2018 16:50:21 +0100 Subject: [PATCH 55/56] Moved HTML5AudioSoundManager.js --- {v3/src => src}/sound/html5/HTML5AudioSoundManager.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {v3/src => src}/sound/html5/HTML5AudioSoundManager.js (100%) diff --git a/v3/src/sound/html5/HTML5AudioSoundManager.js b/src/sound/html5/HTML5AudioSoundManager.js similarity index 100% rename from v3/src/sound/html5/HTML5AudioSoundManager.js rename to src/sound/html5/HTML5AudioSoundManager.js From 04b8f4203eac290df940605806d3d67451de3102 Mon Sep 17 00:00:00 2001 From: Richard Davey Date: Wed, 10 Jan 2018 16:29:37 +0000 Subject: [PATCH 56/56] Started moving plugins to their own folders. --- src/boot/Game.js | 2 +- src/{scene/plugins => data}/Data.js | 6 +++--- src/{scene/plugins => data}/DataStore.js | 2 +- src/scene/local/Systems.js | 12 ++++++++---- 4 files changed, 13 insertions(+), 9 deletions(-) rename src/{scene/plugins => data}/Data.js (97%) rename src/{scene/plugins => data}/DataStore.js (98%) diff --git a/src/boot/Game.js b/src/boot/Game.js index ce10eaf6d..3e5d43aeb 100644 --- a/src/boot/Game.js +++ b/src/boot/Game.js @@ -11,7 +11,7 @@ var VisibilityHandler = require('./VisibilityHandler'); var AnimationManager = require('../animations/manager/AnimationManager'); var CreateRenderer = require('./CreateRenderer'); -var Data = require('../scene/plugins/Data'); +var Data = require('../data/Data'); var GlobalCache = require('../cache/GlobalCache'); var GlobalInputManager = require('../input/global/GlobalInputManager'); var GlobalSceneManager = require('../scene/global/GlobalSceneManager'); diff --git a/src/scene/plugins/Data.js b/src/data/Data.js similarity index 97% rename from src/scene/plugins/Data.js rename to src/data/Data.js index f66c9390e..a38483b25 100644 --- a/src/scene/plugins/Data.js +++ b/src/data/Data.js @@ -1,6 +1,6 @@ -var Class = require('../../utils/Class'); -var Event = require('../../events/Event'); -var EventDispatcher = require('../../events/EventDispatcher'); +var Class = require('../utils/Class'); +var Event = require('../events/Event'); +var EventDispatcher = require('../events/EventDispatcher'); /** * The Data Component features a means to store pieces of data specific to a Game Object, diff --git a/src/scene/plugins/DataStore.js b/src/data/DataStore.js similarity index 98% rename from src/scene/plugins/DataStore.js rename to src/data/DataStore.js index 4cf0209ac..8f44835c2 100644 --- a/src/scene/plugins/DataStore.js +++ b/src/data/DataStore.js @@ -1,4 +1,4 @@ -var Class = require('../../utils/Class'); +var Class = require('../utils/Class'); var Data = require('./Data'); var DataStore = new Class({ diff --git a/src/scene/local/Systems.js b/src/scene/local/Systems.js index 74e6c804b..d40596bf7 100644 --- a/src/scene/local/Systems.js +++ b/src/scene/local/Systems.js @@ -1,8 +1,8 @@ var CameraManager = require('../../camera/local/CameraManager'); var Class = require('../../utils/Class'); var Clock = require('../../time/Clock'); -var Data = require('../plugins/Data'); -var DataStore = require('../plugins/DataStore'); +var Data = require('../../data/Data'); +var DataStore = require('../../data/DataStore'); var DisplayList = require('../plugins/DisplayList'); var EventDispatcher = require('../../events/EventDispatcher'); var GameObjectCreator = require('../plugins/GameObjectCreator'); @@ -16,6 +16,8 @@ var StableSort = require('../../utils/array/StableSort'); var TweenManager = require('../../tweens/manager/TweenManager'); var UpdateList = require('../plugins/UpdateList'); +var PluginManager = require('../../plugins/PluginManager'); + var Systems = new Class({ initialize: @@ -27,8 +29,6 @@ var Systems = new Class({ this.config = config; this.settings = Settings.create(config); - this.renderList = []; - this.sortChildrenFlag = false; // Set by the GlobalSceneManager @@ -59,6 +59,8 @@ var Systems = new Class({ this.time; this.tweens; this.updateList; + + this.plugins; }, init: function (game) @@ -74,6 +76,8 @@ var Systems = new Class({ this.registry = game.registry; this.textures = game.textures; + this.plugins = new PluginManager(scene); + // Scene specific managers (Factory, Tweens, Loader, Physics, etc) this.add = new GameObjectFactory(scene);