Skip to content

Commit 6192152

Browse files
committed
There is a new webpack config FEATURE_SOUND which is set to true by default, but if set to false it will exclude the Sound Manager and all of its systems into the build files.
1 parent f4a86fd commit 6192152

9 files changed

Lines changed: 42 additions & 18 deletions

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ Notes:
8383
* `MultiScriptFile` is a new Loader FileType that allows you to load multiple script files into the document via the Phaser Loader, using the new `load.scripts` method. The difference between this and `load.script` is that you must pass an array of script file URLs to this method and they will be loaded in parallel but _processed_ (i.e. added to the document) in the exact order specified in the array. This allows you to load a bundle of scripts that have dependencies on each other.
8484
* `Key.getDuration` is a new method that will return the duration, in ms, that the Key has been held down for. If the Key isn't down it will return zero.
8585
* The `Container.setScrollFactor` method has a new optional argument `updateChildren`. If set, it will change the `scrollFactor` values of all the Container children as well as the Container. Fix #4466 #4475 (thanks @pinkkis @enriqueto)
86+
* There is a new webpack config `FEATURE_SOUND` which is set to `true` by default, but if set to `false` it will exclude the Sound Manager and all of its systems into the build files. Fix #4428 (thanks @goldfire)
8687

8788
### Updates
8889

src/core/Game.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ var PluginCache = require('../plugins/PluginCache');
2323
var PluginManager = require('../plugins/PluginManager');
2424
var ScaleManager = require('../scale/ScaleManager');
2525
var SceneManager = require('../scene/SceneManager');
26-
var SoundManagerCreator = require('../sound/SoundManagerCreator');
2726
var TextureEvents = require('../textures/events');
2827
var TextureManager = require('../textures/TextureManager');
2928
var TimeStep = require('./TimeStep');
3029
var VisibilityHandler = require('./VisibilityHandler');
3130

31+
if (typeof FEATURE_SOUND)
32+
{
33+
var SoundManagerCreator = require('../sound/SoundManagerCreator');
34+
}
35+
3236
if (typeof PLUGIN_FBINSTANT)
3337
{
3438
var FacebookInstantGamesPlugin = require('../../plugins/fbinstant/src/FacebookInstantGamesPlugin');
@@ -236,16 +240,19 @@ var Game = new Class({
236240
*/
237241
this.scale = new ScaleManager(this, this.config);
238242

239-
/**
240-
* An instance of the base Sound Manager.
241-
*
242-
* The Sound Manager is a global system responsible for the playback and updating of all audio in your game.
243-
*
244-
* @name Phaser.Game#sound
245-
* @type {Phaser.Sound.BaseSoundManager}
246-
* @since 3.0.0
247-
*/
248-
this.sound = SoundManagerCreator.create(this);
243+
if (typeof FEATURE_SOUND)
244+
{
245+
/**
246+
* An instance of the base Sound Manager.
247+
*
248+
* The Sound Manager is a global system responsible for the playback and updating of all audio in your game.
249+
*
250+
* @name Phaser.Game#sound
251+
* @type {Phaser.Sound.BaseSoundManager}
252+
* @since 3.0.0
253+
*/
254+
this.sound = SoundManagerCreator.create(this);
255+
}
249256

250257
/**
251258
* An instance of the Time Step.

src/phaser-arcade-physics.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ var Phaser = {
4040
Scale: require('./scale'),
4141
Scene: require('./scene/Scene'),
4242
Scenes: require('./scene'),
43-
Sound: require('./sound'),
4443
Structs: require('./structs'),
4544
Textures: require('./textures'),
4645
Tilemaps: require('./tilemaps'),
@@ -54,6 +53,11 @@ var Phaser = {
5453

5554
Phaser = Extend(false, Phaser, CONST);
5655

56+
if (typeof FEATURE_SOUND)
57+
{
58+
Phaser.Sound = require('./sound');
59+
}
60+
5761
// Export it
5862

5963
module.exports = Phaser;

src/phaser-core.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ var Phaser = {
8888
Scale: require('./scale'),
8989
Scene: require('./scene/Scene'),
9090
Scenes: require('./scene'),
91-
Sound: require('./sound'),
9291
Structs: require('./structs'),
9392
Textures: require('./textures'),
9493
Time: require('./time'),
@@ -101,6 +100,11 @@ Phaser = Extend(false, Phaser, CONST);
101100

102101
// Export it
103102

103+
if (typeof FEATURE_SOUND)
104+
{
105+
Phaser.Sound = require('./sound');
106+
}
107+
104108
module.exports = Phaser;
105109

106110
global.Phaser = Phaser;

src/phaser.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ var Phaser = {
3939
Scale: require('./scale'),
4040
Scene: require('./scene/Scene'),
4141
Scenes: require('./scene'),
42-
Sound: require('./sound'),
4342
Structs: require('./structs'),
4443
Textures: require('./textures'),
4544
Tilemaps: require('./tilemaps'),
@@ -51,6 +50,11 @@ var Phaser = {
5150

5251
// Merge in the optional plugins
5352

53+
if (typeof FEATURE_SOUND)
54+
{
55+
Phaser.Sound = require('./sound');
56+
}
57+
5458
if (typeof PLUGIN_CAMERA3D)
5559
{
5660
Phaser.Cameras.Sprite3D = require('../plugins/camera3d/src');

webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ module.exports = {
3131
"typeof WEBGL_RENDERER": JSON.stringify(true),
3232
"typeof EXPERIMENTAL": JSON.stringify(true),
3333
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
34-
"typeof PLUGIN_FBINSTANT": JSON.stringify(false)
34+
"typeof PLUGIN_FBINSTANT": JSON.stringify(false),
35+
"typeof FEATURE_SOUND": JSON.stringify(true)
3536
}),
3637
{
3738
apply: (compiler) => {

webpack.dist.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ module.exports = {
5050
"typeof WEBGL_RENDERER": JSON.stringify(true),
5151
"typeof EXPERIMENTAL": JSON.stringify(false),
5252
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
53-
"typeof PLUGIN_FBINSTANT": JSON.stringify(false)
53+
"typeof PLUGIN_FBINSTANT": JSON.stringify(false),
54+
"typeof FEATURE_SOUND": JSON.stringify(true)
5455
}),
5556

5657
new CleanWebpackPlugin([ 'dist' ])

webpack.fb.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ module.exports = {
3131
"typeof WEBGL_RENDERER": JSON.stringify(true),
3232
"typeof EXPERIMENTAL": JSON.stringify(false),
3333
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
34-
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
34+
"typeof PLUGIN_FBINSTANT": JSON.stringify(true),
35+
"typeof FEATURE_SOUND": JSON.stringify(true)
3536
}),
3637
{
3738
apply: (compiler) => {

webpack.fb.dist.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ module.exports = {
4747
"typeof WEBGL_RENDERER": JSON.stringify(true),
4848
"typeof EXPERIMENTAL": JSON.stringify(false),
4949
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
50-
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
50+
"typeof PLUGIN_FBINSTANT": JSON.stringify(true),
51+
"typeof FEATURE_SOUND": JSON.stringify(true)
5152
})
5253
]
5354
};

0 commit comments

Comments
 (0)