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.

This commit is contained in:
Richard Davey 2019-04-24 12:23:21 +01:00
parent f4a86fd368
commit 61921525f1
9 changed files with 42 additions and 18 deletions

View file

@ -83,6 +83,7 @@ Notes:
* `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.
* `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.
* 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)
* 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)
### Updates

View file

@ -23,12 +23,16 @@ var PluginCache = require('../plugins/PluginCache');
var PluginManager = require('../plugins/PluginManager');
var ScaleManager = require('../scale/ScaleManager');
var SceneManager = require('../scene/SceneManager');
var SoundManagerCreator = require('../sound/SoundManagerCreator');
var TextureEvents = require('../textures/events');
var TextureManager = require('../textures/TextureManager');
var TimeStep = require('./TimeStep');
var VisibilityHandler = require('./VisibilityHandler');
if (typeof FEATURE_SOUND)
{
var SoundManagerCreator = require('../sound/SoundManagerCreator');
}
if (typeof PLUGIN_FBINSTANT)
{
var FacebookInstantGamesPlugin = require('../../plugins/fbinstant/src/FacebookInstantGamesPlugin');
@ -236,16 +240,19 @@ var Game = new Class({
*/
this.scale = new ScaleManager(this, this.config);
/**
* An instance of the base Sound Manager.
*
* The Sound Manager is a global system responsible for the playback and updating of all audio in your game.
*
* @name Phaser.Game#sound
* @type {Phaser.Sound.BaseSoundManager}
* @since 3.0.0
*/
this.sound = SoundManagerCreator.create(this);
if (typeof FEATURE_SOUND)
{
/**
* An instance of the base Sound Manager.
*
* The Sound Manager is a global system responsible for the playback and updating of all audio in your game.
*
* @name Phaser.Game#sound
* @type {Phaser.Sound.BaseSoundManager}
* @since 3.0.0
*/
this.sound = SoundManagerCreator.create(this);
}
/**
* An instance of the Time Step.

View file

@ -40,7 +40,6 @@ var Phaser = {
Scale: require('./scale'),
Scene: require('./scene/Scene'),
Scenes: require('./scene'),
Sound: require('./sound'),
Structs: require('./structs'),
Textures: require('./textures'),
Tilemaps: require('./tilemaps'),
@ -54,6 +53,11 @@ var Phaser = {
Phaser = Extend(false, Phaser, CONST);
if (typeof FEATURE_SOUND)
{
Phaser.Sound = require('./sound');
}
// Export it
module.exports = Phaser;

View file

@ -88,7 +88,6 @@ var Phaser = {
Scale: require('./scale'),
Scene: require('./scene/Scene'),
Scenes: require('./scene'),
Sound: require('./sound'),
Structs: require('./structs'),
Textures: require('./textures'),
Time: require('./time'),
@ -101,6 +100,11 @@ Phaser = Extend(false, Phaser, CONST);
// Export it
if (typeof FEATURE_SOUND)
{
Phaser.Sound = require('./sound');
}
module.exports = Phaser;
global.Phaser = Phaser;

View file

@ -39,7 +39,6 @@ var Phaser = {
Scale: require('./scale'),
Scene: require('./scene/Scene'),
Scenes: require('./scene'),
Sound: require('./sound'),
Structs: require('./structs'),
Textures: require('./textures'),
Tilemaps: require('./tilemaps'),
@ -51,6 +50,11 @@ var Phaser = {
// Merge in the optional plugins
if (typeof FEATURE_SOUND)
{
Phaser.Sound = require('./sound');
}
if (typeof PLUGIN_CAMERA3D)
{
Phaser.Cameras.Sprite3D = require('../plugins/camera3d/src');

View file

@ -31,7 +31,8 @@ module.exports = {
"typeof WEBGL_RENDERER": JSON.stringify(true),
"typeof EXPERIMENTAL": JSON.stringify(true),
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
"typeof PLUGIN_FBINSTANT": JSON.stringify(false)
"typeof PLUGIN_FBINSTANT": JSON.stringify(false),
"typeof FEATURE_SOUND": JSON.stringify(true)
}),
{
apply: (compiler) => {

View file

@ -50,7 +50,8 @@ module.exports = {
"typeof WEBGL_RENDERER": JSON.stringify(true),
"typeof EXPERIMENTAL": JSON.stringify(false),
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
"typeof PLUGIN_FBINSTANT": JSON.stringify(false)
"typeof PLUGIN_FBINSTANT": JSON.stringify(false),
"typeof FEATURE_SOUND": JSON.stringify(true)
}),
new CleanWebpackPlugin([ 'dist' ])

View file

@ -31,7 +31,8 @@ module.exports = {
"typeof WEBGL_RENDERER": JSON.stringify(true),
"typeof EXPERIMENTAL": JSON.stringify(false),
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
"typeof PLUGIN_FBINSTANT": JSON.stringify(true),
"typeof FEATURE_SOUND": JSON.stringify(true)
}),
{
apply: (compiler) => {

View file

@ -47,7 +47,8 @@ module.exports = {
"typeof WEBGL_RENDERER": JSON.stringify(true),
"typeof EXPERIMENTAL": JSON.stringify(false),
"typeof PLUGIN_CAMERA3D": JSON.stringify(false),
"typeof PLUGIN_FBINSTANT": JSON.stringify(true)
"typeof PLUGIN_FBINSTANT": JSON.stringify(true),
"typeof FEATURE_SOUND": JSON.stringify(true)
})
]
};