Various small fixes

This commit is contained in:
Richard Davey
2013-08-09 17:02:47 +01:00
parent e002827a20
commit 8b2f1cca51
5 changed files with 89 additions and 90 deletions
+11 -6
View File
@@ -86,6 +86,11 @@ module Phaser {
*/
public crossOrigin: string = '';
// If you want to append a URL before the path of any asset you can set this here.
// Useful if you need to allow an asset url to be configured outside of the game code.
// MUST have / on the end of it!
public baseURL: string = '';
public onFileComplete: Phaser.Signal;
public onFileError: Phaser.Signal;
public onLoadStart: Phaser.Signal;
@@ -326,7 +331,7 @@ module Phaser {
file.data.onload = () => this.fileComplete(file.key);
file.data.onerror = () => this.fileError(file.key);
file.data.crossOrigin = this.crossOrigin;
file.data.src = file.url;
file.data.src = this.baseURL + file.url;
break;
case 'audio':
@@ -338,7 +343,7 @@ module Phaser {
// WebAudio or Audio Tag?
if (this.game.sound.usingWebAudio)
{
this._xhr.open("GET", file.url, true);
this._xhr.open("GET", this.baseURL + file.url, true);
this._xhr.responseType = "arraybuffer";
this._xhr.onload = () => this.fileComplete(file.key);
this._xhr.onerror = () => this.fileError(file.key);
@@ -352,7 +357,7 @@ module Phaser {
file.data = new Audio();
file.data.name = file.key;
file.data.preload = 'auto';
file.data.src = file.url;
file.data.src = this.baseURL + file.url;
this.fileComplete(file.key);
}
else
@@ -361,7 +366,7 @@ module Phaser {
file.data.name = file.key;
file.data.onerror = () => this.fileError(file.key);
file.data.preload = 'auto';
file.data.src = file.url;
file.data.src = this.baseURL + file.url;
file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false);
file.data.load();
}
@@ -371,7 +376,7 @@ module Phaser {
break;
case 'text':
this._xhr.open("GET", file.url, true);
this._xhr.open("GET", this.baseURL + file.url, true);
this._xhr.responseType = "text";
this._xhr.onload = () => this.fileComplete(file.key);
this._xhr.onerror = () => this.fileError(file.key);
@@ -454,7 +459,7 @@ module Phaser {
{
// Load the JSON or XML before carrying on with the next file
loadNext = false;
this._xhr.open("GET", file.atlasURL, true);
this._xhr.open("GET", this.baseURL + file.atlasURL, true);
this._xhr.responseType = "text";
if (file.format == Loader.TEXTURE_ATLAS_JSON_ARRAY)