forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBitmapFontFile.js
More file actions
72 lines (63 loc) · 2.47 KB
/
BitmapFontFile.js
File metadata and controls
72 lines (63 loc) · 2.47 KB
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
64
65
66
67
68
69
70
71
72
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
var FileTypesManager = require('../FileTypesManager');
var ImageFile = require('./ImageFile.js');
var XMLFile = require('./XMLFile.js');
/**
* An Bitmap Font File.
*
* @function Phaser.Loader.Filetypes.BitmapFontFile
* @since 3.0.0
*
* @param {string} key - The key of the file within the loader.
* @param {string} textureURL - The url to load the texture file from.
* @param {string} xmlURL - The url to load the atlas file from.
* @param {string} path - The path of the file.
* @param {object} textureXhrSettings - Optional texture file specific XHR settings.
* @param {object} xmlXhrSettings - Optional atlas file specific XHR settings.
*
* @return {object} An object containing two File objects to be added to the loader.
*/
var BitmapFontFile = function (key, textureURL, xmlURL, path, textureXhrSettings, xmlXhrSettings)
{
var image = new ImageFile(key, textureURL, path, textureXhrSettings);
var data = new XMLFile(key, xmlURL, path, xmlXhrSettings);
// Link them together
image.linkFile = data;
data.linkFile = image;
// Set the type
image.linkType = 'bitmapfont';
data.linkType = 'bitmapfont';
return { texture: image, data: data };
};
/**
* Adds a Bitmap Font file to the current load queue.
*
* Note: This method will only be available if the Bitmap Font File type has been built into Phaser.
*
* The file is **not** loaded immediately after calling this method.
* Instead, the file is added to a queue within the Loader, which is processed automatically when the Loader starts.
*
* @method Phaser.Loader.LoaderPlugin#bitmapFont
* @since 3.0.0
*
* @param {string} key - [description]
* @param {string} textureURL - [description]
* @param {string} xmlURL - [description]
* @param {object} textureXhrSettings - [description]
* @param {object} xmlXhrSettings - [description]
*
* @return {Phaser.Loader.LoaderPlugin} The Loader.
*/
FileTypesManager.register('bitmapFont', function (key, textureURL, xmlURL, textureXhrSettings, xmlXhrSettings)
{
// Returns an object with two properties: 'texture' and 'data'
var files = new BitmapFontFile(key, textureURL, xmlURL, this.path, textureXhrSettings, xmlXhrSettings);
this.addFile(files.texture);
this.addFile(files.data);
return this;
});
module.exports = BitmapFontFile;