mirror of
https://github.com/wassname/phaser.git
synced 2026-09-09 11:28:47 +08:00
New non-conflicting Loading system in place. Creating tests.
This commit is contained in:
+18
-18
@@ -46,12 +46,6 @@ Phaser.Loader = function (game) {
|
||||
*/
|
||||
this._xhr = new XMLHttpRequest();
|
||||
|
||||
/**
|
||||
* @property {number} - Length of assets queue.
|
||||
* @default
|
||||
*/
|
||||
this.queueSize = 0;
|
||||
|
||||
/**
|
||||
* @property {boolean} isLoading - True if the Loader is in the process of loading the queue.
|
||||
* @default
|
||||
@@ -250,6 +244,8 @@ Phaser.Loader.prototype = {
|
||||
loaded: false
|
||||
};
|
||||
|
||||
console.log('addToFileList', entry);
|
||||
|
||||
if (typeof properties !== "undefined")
|
||||
{
|
||||
for (var prop in properties)
|
||||
@@ -685,6 +681,8 @@ Phaser.Loader.prototype = {
|
||||
*/
|
||||
start: function () {
|
||||
|
||||
console.log('Loader start', this._fileList);
|
||||
|
||||
if (this.isLoading)
|
||||
{
|
||||
return;
|
||||
@@ -733,10 +731,10 @@ Phaser.Loader.prototype = {
|
||||
file.data = new Image();
|
||||
file.data.name = file.key;
|
||||
file.data.onload = function () {
|
||||
return _this.fileComplete(this._fileIndex);
|
||||
return _this.fileComplete(_this._fileIndex);
|
||||
};
|
||||
file.data.onerror = function () {
|
||||
return _this.fileError(this._fileIndex);
|
||||
return _this.fileError(_this._fileIndex);
|
||||
};
|
||||
file.data.crossOrigin = this.crossOrigin;
|
||||
file.data.src = this.baseURL + file.url;
|
||||
@@ -753,10 +751,10 @@ Phaser.Loader.prototype = {
|
||||
this._xhr.open("GET", this.baseURL + file.url, true);
|
||||
this._xhr.responseType = "arraybuffer";
|
||||
this._xhr.onload = function () {
|
||||
return _this.fileComplete(this._fileIndex);
|
||||
return _this.fileComplete(_this._fileIndex);
|
||||
};
|
||||
this._xhr.onerror = function () {
|
||||
return _this.fileError(this._fileIndex);
|
||||
return _this.fileError(_this._fileIndex);
|
||||
};
|
||||
this._xhr.send();
|
||||
}
|
||||
@@ -776,7 +774,7 @@ Phaser.Loader.prototype = {
|
||||
file.data = new Audio();
|
||||
file.data.name = file.key;
|
||||
file.data.onerror = function () {
|
||||
return _this.fileError(this._fileIndex);
|
||||
return _this.fileError(_this._fileIndex);
|
||||
};
|
||||
file.data.preload = 'auto';
|
||||
file.data.src = this.baseURL + file.url;
|
||||
@@ -799,13 +797,13 @@ Phaser.Loader.prototype = {
|
||||
if (file.format == Phaser.Tilemap.TILED_JSON)
|
||||
{
|
||||
this._xhr.onload = function () {
|
||||
return _this.jsonLoadComplete(this._fileIndex);
|
||||
return _this.jsonLoadComplete(_this._fileIndex);
|
||||
};
|
||||
}
|
||||
else if (file.format == Phaser.Tilemap.CSV)
|
||||
{
|
||||
this._xhr.onload = function () {
|
||||
return _this.csvLoadComplete(this._fileIndex);
|
||||
return _this.csvLoadComplete(_this._fileIndex);
|
||||
};
|
||||
}
|
||||
else
|
||||
@@ -814,7 +812,7 @@ Phaser.Loader.prototype = {
|
||||
}
|
||||
|
||||
this._xhr.onerror = function () {
|
||||
return _this.dataLoadError(this._fileIndex);
|
||||
return _this.dataLoadError(_this._fileIndex);
|
||||
};
|
||||
this._xhr.send();
|
||||
break;
|
||||
@@ -823,10 +821,10 @@ Phaser.Loader.prototype = {
|
||||
this._xhr.open("GET", this.baseURL + file.url, true);
|
||||
this._xhr.responseType = "text";
|
||||
this._xhr.onload = function () {
|
||||
return _this.fileComplete(this._fileIndex);
|
||||
return _this.fileComplete(_this._fileIndex);
|
||||
};
|
||||
this._xhr.onerror = function () {
|
||||
return _this.fileError(this._fileIndex);
|
||||
return _this.fileError(_this._fileIndex);
|
||||
};
|
||||
this._xhr.send();
|
||||
break;
|
||||
@@ -889,6 +887,8 @@ Phaser.Loader.prototype = {
|
||||
*/
|
||||
fileComplete: function (index) {
|
||||
|
||||
console.log('fileComplete', index);
|
||||
|
||||
if (!this._fileList[index])
|
||||
{
|
||||
console.warn('Phaser.Loader fileComplete invalid index ' + index);
|
||||
@@ -1189,7 +1189,7 @@ Phaser.Loader.prototype = {
|
||||
|
||||
var total = 0;
|
||||
|
||||
for (var i = 0; i < this._fileList; i++)
|
||||
for (var i = 0; i < this._fileList.length; i++)
|
||||
{
|
||||
if (this._fileList[i].loaded)
|
||||
{
|
||||
@@ -1210,7 +1210,7 @@ Phaser.Loader.prototype = {
|
||||
|
||||
var total = 0;
|
||||
|
||||
for (var i = 0; i < this._fileList; i++)
|
||||
for (var i = 0; i < this._fileList.length; i++)
|
||||
{
|
||||
if (this._fileList[i].loaded === false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user