Loader.replaceInFileList wouldn't over-write the previous entry correctly, which caused the Loader.image overwrite parameter to fail (thanks basoko, fixes #493)

This commit is contained in:
photonstorm
2014-02-27 21:41:54 +00:00
parent 7e12075be1
commit 10b3dbf74a
2 changed files with 33 additions and 1 deletions
+1
View File
@@ -183,6 +183,7 @@ Bug Fixes:
* You can now safely destroy a Group and the 'destroyChildren' boolean will propogate fully down the display list.
* Calling destroy on an already destroyed object would throw a run-time error. Now checked for and aborted.
* Calling destroy while in an Input Event callback now works for either the parent Group or the calling object itself.
* Loader.replaceInFileList wouldn't over-write the previous entry correctly, which caused the Loader.image overwrite parameter to fail (thanks basoko, fixes #493)
TO DO:
+32 -1
View File
@@ -198,6 +198,31 @@ Phaser.Loader.prototype = {
},
/**
* Gets the fileList index for the given key.
*
* @method Phaser.Loader#getAssetIndex
* @param {string} type - The type asset you want to check.
* @param {string} key - Key of the asset you want to check.
* @return {number} The index of this key in the filelist, or -1 if not found.
*/
getAssetIndex: function (type, key) {
if (this._fileList.length > 0)
{
for (var i = 0; i < this._fileList.length; i++)
{
if (this._fileList[i].type === type && this._fileList[i].key === key)
{
return i;
}
}
}
return -1;
},
/**
* Gets the asset that is queued for load.
*
@@ -302,10 +327,16 @@ Phaser.Loader.prototype = {
}
}
if (this.checkKeyExists(type, key) === false)
var index = this.getAssetIndex(type, key);
if (index === -1)
{
this._fileList.push(entry);
}
else
{
this._fileList[index] = entry;
}
},