Skip to content

Commit 1062b73

Browse files
committed
Loader - fix/update for getAssetIndex
Loaded/loading assets are skipped if they have been superceded. This makes the behavior consistent with respect to `addToFileList`, if the queue is inspected or modified while loading.
1 parent d943217 commit 1062b73

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/loader/Loader.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,23 @@ Phaser.Loader.prototype = {
318318
*/
319319
getAssetIndex: function (type, key) {
320320

321+
var bestFound = -1;
322+
321323
for (var i = 0; i < this._fileList.length; i++)
322324
{
323-
if (this._fileList[i].type === type && this._fileList[i].key === key)
325+
var file = this._fileList[i];
326+
if (file.type === type && file.key === key)
324327
{
325-
return i;
328+
bestFound = i;
329+
// An already loaded/loading file may be superceded.
330+
if (!file.loaded && !file.loading)
331+
{
332+
break;
333+
}
326334
}
327335
}
328336

329-
return -1;
337+
return bestFound;
330338

331339
},
332340

0 commit comments

Comments
 (0)