You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/loader/Loader.js
+27-11Lines changed: 27 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -9,41 +9,49 @@
9
9
* The Loader handles loading all external content such as Images, Sounds, Texture Atlases and data files.
10
10
* It uses a combination of tag loading (eg. Image elements) and XHR and provides progress and completion callbacks.
11
11
*
12
+
* Parallel loading is supported but must be enabled explicitly with {@link Phaser.Loader#enableParallelDownloads enableParallelDownloads}.
13
+
* Load-before behavior of parallel resources is controlled by synchronization points as discussed in {@link Phaser.Loader#withSyncPoint withSyncPoint}.
14
+
*
12
15
* @class Phaser.Loader
13
16
* @constructor
14
17
* @param {Phaser.Game} game - A reference to the currently running game.
15
18
*/
16
19
Phaser.Loader=function(game){
17
20
18
21
/**
19
-
* @property {Phaser.Game} game - Local reference to game.
22
+
* Local reference to game.
23
+
* @property {Phaser.Game} game
24
+
* @protected
20
25
*/
21
26
this.game=game;
22
27
23
28
/**
24
-
* @property {boolean} isLoading - True if the Loader is in the process of loading the queue.
29
+
* True if the Loader is in the process of loading the queue.
30
+
* @property {boolean} isLoading
25
31
* @default
26
32
*/
27
33
this.isLoading=false;
28
34
29
35
/**
30
-
* @property {boolean} hasLoaded - True if all assets in the queue have finished loading.
36
+
* True if all assets in the queue have finished loading.
37
+
* @property {boolean} hasLoaded
31
38
* @default
32
39
*/
33
40
this.hasLoaded=false;
34
41
35
42
/**
36
-
* You can optionally link a sprite to the preloader.
43
+
* You can optionally link a progress sprite with {@link Phaser.Loader#setPreloadSprite setPreloadSprite}.
37
44
*
38
-
* The Sprites width or height will be cropped based on the percentage loaded.
39
45
* This property is an object containing: sprite, rect, direction, width and height
40
46
*
41
47
* @property {?object} preloadSprite
48
+
* @protected
42
49
*/
43
50
this.preloadSprite=null;
44
51
45
52
/**
46
-
* @property {boolean|string} crossOrigin - The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'.
53
+
* The crossOrigin value applied to loaded images. Very often this needs to be set to 'anonymous'.
54
+
* @property {boolean|string} crossOrigin
47
55
* @default
48
56
*/
49
57
this.crossOrigin=false;
@@ -111,7 +119,9 @@ Phaser.Loader = function (game) {
111
119
this.onFileError=newPhaser.Signal();
112
120
113
121
/**
114
-
* @property {boolean} useXDomainRequest - If true and if the browser supports XDomainRequest, it will be used in preference for XHR when loading JSON files (it does not affect other file types). This is only relevant for IE9 and should only be enabled when you know your server/CDN requires it.
122
+
* If true and if the browser supports XDomainRequest, it will be used in preference for XHR when loading JSON files (it does not affect other file types).
123
+
* This is only relevant for IE9 and should only be enabled when required by the server/CDN.
124
+
* @property {boolean} useXDomainRequest
115
125
*/
116
126
this.useXDomainRequest=false;
117
127
@@ -124,22 +134,24 @@ Phaser.Loader = function (game) {
124
134
125
135
/**
126
136
* The number of concurrent assets to try and fetch at once.
127
-
* Most browsers limit 6 requests per host.
137
+
* Most browsers limit 6 requests per domain.
128
138
*
129
139
* @property {integer} maxParallelDownloads
130
140
* @protected
131
141
*/
132
142
this.maxParallelDownloads=5;
133
143
134
144
/**
135
-
* A counter: if more than zero files will be automatically added as a synchronization point.
145
+
* A counter: if more than zero, files will be automatically added as a synchronization point.
136
146
* @property {integer} _withSyncPointDepth;
137
147
*/
138
148
this._withSyncPointDepth=0;
139
149
140
150
/**
141
151
* Contains all the information for asset files (including packs) to load.
142
152
*
153
+
* File/assets are only removed from the list after all loading completes.
154
+
*
143
155
* @property {array} _fileList
144
156
* @private
145
157
*/
@@ -1027,7 +1039,7 @@ Phaser.Loader.prototype = {
1027
1039
/**
1028
1040
* Remove a file/asset from the loading queue.
1029
1041
*
1030
-
* A file that has already started loading cannot be removed.
1042
+
* A file that is loaded or has started loading cannot be removed.
1031
1043
*
1032
1044
* @method Phaser.Loader#removeFile
1033
1045
* @protected
@@ -1088,7 +1100,7 @@ Phaser.Loader.prototype = {
1088
1100
*
1089
1101
* If a sync-file is encountered then subsequent asset processing is delayed until it completes.
1090
1102
* The exception to this rule is that packfiles can be downloaded (but not processed) even if
1091
-
* there appear other sync files (ie. packs) - this enables multiple packfiles to be fetched asynchronously,
1103
+
* there appear other sync files (ie. packs) - this enables multiple packfiles to be fetched in parallel.
1092
1104
* such as during the start phaser.
1093
1105
*
1094
1106
* @method Phaser.Loader#processLoadQueue
@@ -2050,6 +2062,7 @@ Phaser.Loader.prototype = {
2050
2062
* Returns the number of files that have already been loaded, even if they errored.
2051
2063
*
2052
2064
* @method Phaser.Loader#totalLoadedFiles
2065
+
* @protected
2053
2066
* @return {number} The number of files that have already been loaded (even if they errored)
2054
2067
*/
2055
2068
totalLoadedFiles: function(){
@@ -2062,6 +2075,7 @@ Phaser.Loader.prototype = {
2062
2075
* Returns the number of files still waiting to be processed in the load queue. This value decreases as each file in the queue is loaded.
2063
2076
*
2064
2077
* @method Phaser.Loader#totalQueuedFiles
2078
+
* @protected
2065
2079
* @return {number} The number of files that still remain in the load queue.
2066
2080
*/
2067
2081
totalQueuedFiles: function(){
@@ -2074,6 +2088,7 @@ Phaser.Loader.prototype = {
2074
2088
* Returns the number of asset packs that have already been loaded, even if they errored.
2075
2089
*
2076
2090
* @method Phaser.Loader#totalLoadedPacks
2091
+
* @protected
2077
2092
* @return {number} The number of asset packs that have already been loaded (even if they errored)
2078
2093
*/
2079
2094
totalLoadedPacks: function(){
@@ -2086,6 +2101,7 @@ Phaser.Loader.prototype = {
2086
2101
* Returns the number of asset packs still waiting to be processed in the load queue. This value decreases as each pack in the queue is loaded.
2087
2102
*
2088
2103
* @method Phaser.Loader#totalQueuedPacks
2104
+
* @protected
2089
2105
* @return {number} The number of asset packs that still remain in the load queue.
0 commit comments