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:
Paul 2014-11-22 17:42:12 -08:00
parent d94321702a
commit 1062b7330e

View file

@ -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;
},