/
FileTypesManager.js
63 lines (55 loc) · 1.57 KB
/
FileTypesManager.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
var types = {};
/**
* @namespace Phaser.Loader.FileTypesManager
*/
var FileTypesManager = {
/**
* Static method called when a LoaderPlugin is created.
*
* Loops through the local types object and injects all of them as
* properties into the LoaderPlugin instance.
*
* @method Phaser.Loader.FileTypesManager.install
* @since 3.0.0
*
* @param {Phaser.Loader.LoaderPlugin} loader - The LoaderPlugin to install the types into.
*/
install: function (loader)
{
for (var key in types)
{
loader[key] = types[key];
}
},
/**
* Static method called directly by the File Types.
*
* The key is a reference to the function used to load the files via the Loader, i.e. `image`.
*
* @method Phaser.Loader.FileTypesManager.register
* @since 3.0.0
*
* @param {string} key - The key that will be used as the method name in the LoaderPlugin.
* @param {function} factoryFunction - The function that will be called when LoaderPlugin.key is invoked.
*/
register: function (key, factoryFunction)
{
types[key] = factoryFunction;
},
/**
* Removed all associated file types.
*
* @method Phaser.Loader.FileTypesManager.destroy
* @since 3.0.0
*/
destroy: function ()
{
types = {};
}
};
module.exports = FileTypesManager;