mirror of
https://github.com/photonstorm/phaser
synced 2025-02-26 04:17:08 +00:00
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.
This commit is contained in:
parent
d94321702a
commit
1062b7330e
1 changed files with 11 additions and 3 deletions
|
@ -318,15 +318,23 @@ Phaser.Loader.prototype = {
|
|||
*/
|
||||
getAssetIndex: function (type, key) {
|
||||
|
||||
var bestFound = -1;
|
||||
|
||||
for (var i = 0; i < this._fileList.length; i++)
|
||||
{
|
||||
if (this._fileList[i].type === type && this._fileList[i].key === key)
|
||||
var file = this._fileList[i];
|
||||
if (file.type === type && file.key === key)
|
||||
{
|
||||
return i;
|
||||
bestFound = i;
|
||||
// An already loaded/loading file may be superceded.
|
||||
if (!file.loaded && !file.loading)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return bestFound;
|
||||
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue