@@ -13120,6 +13120,10 @@ var Phaser;
1312013120 * @type {string}
1312113121 */
1312213122 this.crossOrigin = '';
13123+ // If you want to append a URL before the path of any asset you can set this here.
13124+ // Useful if you need to allow an asset url to be configured outside of the game code.
13125+ // MUST have / on the end of it!
13126+ this.baseURL = '';
1312313127 this.game = game;
1312413128
1312513129 this._keys = [];
@@ -13326,15 +13330,15 @@ var Phaser;
1332613330 return _this.fileError(file.key);
1332713331 };
1332813332 file.data.crossOrigin = this.crossOrigin;
13329- file.data.src = file.url;
13333+ file.data.src = this.baseURL + file.url;
1333013334 break;
1333113335
1333213336 case 'audio':
1333313337 file.url = this.getAudioURL(file.url);
1333413338
1333513339 if (file.url !== null) {
1333613340 if (this.game.sound.usingWebAudio) {
13337- this._xhr.open("GET", file.url, true);
13341+ this._xhr.open("GET", this.baseURL + file.url, true);
1333813342 this._xhr.responseType = "arraybuffer";
1333913343 this._xhr.onload = function () {
1334013344 return _this.fileComplete(file.key);
@@ -13349,7 +13353,7 @@ var Phaser;
1334913353 file.data = new Audio();
1335013354 file.data.name = file.key;
1335113355 file.data.preload = 'auto';
13352- file.data.src = file.url;
13356+ file.data.src = this.baseURL + file.url;
1335313357 this.fileComplete(file.key);
1335413358 } else {
1335513359 file.data = new Audio();
@@ -13358,7 +13362,7 @@ var Phaser;
1335813362 return _this.fileError(file.key);
1335913363 };
1336013364 file.data.preload = 'auto';
13361- file.data.src = file.url;
13365+ file.data.src = this.baseURL + file.url;
1336213366 file.data.addEventListener('canplaythrough', Phaser.GAMES[this.game.id].load.fileComplete(file.key), false);
1336313367 file.data.load();
1336413368 }
@@ -13368,7 +13372,7 @@ var Phaser;
1336813372 break;
1336913373
1337013374 case 'text':
13371- this._xhr.open("GET", file.url, true);
13375+ this._xhr.open("GET", this.baseURL + file.url, true);
1337213376 this._xhr.responseType = "text";
1337313377 this._xhr.onload = function () {
1337413378 return _this.fileComplete(file.key);
@@ -13442,7 +13446,7 @@ var Phaser;
1344213446 } else {
1344313447 // Load the JSON or XML before carrying on with the next file
1344413448 loadNext = false;
13445- this._xhr.open("GET", file.atlasURL, true);
13449+ this._xhr.open("GET", this.baseURL + file.atlasURL, true);
1344613450 this._xhr.responseType = "text";
1344713451
1344813452 if (file.format == Loader.TEXTURE_ATLAS_JSON_ARRAY) {
@@ -14796,71 +14800,6 @@ var Phaser;
1479614800 enumerable: true,
1479714801 configurable: true
1479814802 });
14799-
14800- // MOVE THESE TO A UTIL
14801- Body.prototype.render = function (context) {
14802- context.beginPath();
14803- context.strokeStyle = 'rgb(0,255,0)';
14804- context.strokeRect(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight, this.bounds.width, this.bounds.height);
14805- context.stroke();
14806- context.closePath();
14807-
14808- // center point
14809- context.fillStyle = 'rgb(0,255,0)';
14810- context.fillRect(this.position.x, this.position.y, 2, 2);
14811-
14812- if (this.touching & Phaser.Types.LEFT) {
14813- context.beginPath();
14814- context.strokeStyle = 'rgb(255,0,0)';
14815- context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
14816- context.lineTo(this.position.x - this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
14817- context.stroke();
14818- context.closePath();
14819- }
14820- if (this.touching & Phaser.Types.RIGHT) {
14821- context.beginPath();
14822- context.strokeStyle = 'rgb(255,0,0)';
14823- context.moveTo(this.position.x + this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
14824- context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
14825- context.stroke();
14826- context.closePath();
14827- }
14828-
14829- if (this.touching & Phaser.Types.UP) {
14830- context.beginPath();
14831- context.strokeStyle = 'rgb(255,0,0)';
14832- context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
14833- context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y - this.bounds.halfHeight);
14834- context.stroke();
14835- context.closePath();
14836- }
14837- if (this.touching & Phaser.Types.DOWN) {
14838- context.beginPath();
14839- context.strokeStyle = 'rgb(255,0,0)';
14840- context.moveTo(this.position.x - this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
14841- context.lineTo(this.position.x + this.bounds.halfWidth, this.position.y + this.bounds.halfHeight);
14842- context.stroke();
14843- context.closePath();
14844- }
14845- };
14846-
14847- /**
14848- * Render debug infos. (including name, bounds info, position and some other properties)
14849- * @param x {number} X position of the debug info to be rendered.
14850- * @param y {number} Y position of the debug info to be rendered.
14851- * @param [color] {number} color of the debug info to be rendered. (format is css color string)
14852- */
14853- Body.prototype.renderDebugInfo = function (x, y, color) {
14854- if (typeof color === "undefined") { color = 'rgb(255,255,255)'; }
14855- this.sprite.texture.context.fillStyle = color;
14856- this.sprite.texture.context.fillText('Sprite: (' + this.sprite.width + ' x ' + this.sprite.height + ')', x, y);
14857-
14858- //this.sprite.texture.context.fillText('x: ' + this._sprite.frameBounds.x.toFixed(1) + ' y: ' + this._sprite.frameBounds.y.toFixed(1) + ' rotation: ' + this._sprite.rotation.toFixed(1), x, y + 14);
14859- this.sprite.texture.context.fillText('x: ' + this.bounds.x.toFixed(1) + ' y: ' + this.bounds.y.toFixed(1) + ' rotation: ' + this.sprite.transform.rotation.toFixed(0), x, y + 14);
14860- this.sprite.texture.context.fillText('vx: ' + this.velocity.x.toFixed(1) + ' vy: ' + this.velocity.y.toFixed(1), x, y + 28);
14861- this.sprite.texture.context.fillText('acx: ' + this.acceleration.x.toFixed(1) + ' acy: ' + this.acceleration.y.toFixed(1), x, y + 42);
14862- this.sprite.texture.context.fillText('angVx: ' + this.angularVelocity.toFixed(1) + ' angAc: ' + this.angularAcceleration.toFixed(1), x, y + 56);
14863- };
1486414803 return Body;
1486514804 })();
1486614805 Physics.Body = Body;
@@ -15013,7 +14952,7 @@ var Phaser;
1501314952 */
1501414953 Sprite.prototype.bringToTop = function () {
1501514954 if (this.group) {
15016- // this.group.bringToTop(this);
14955+ this.group.bringToTop(this);
1501714956 }
1501814957 };
1501914958
@@ -19757,7 +19696,7 @@ var Phaser;
1975719696 //this.physics = new Phaser.Physics.Manager(this);
1975819697 this.plugins = new Phaser.PluginManager(this, this);
1975919698
19760- this.load.onLoadComplete.addOnce (this.loadComplete, this);
19699+ this.load.onLoadComplete.add (this.loadComplete, this);
1976119700
1976219701 this.setRenderer(Phaser.Types.RENDERER_CANVAS);
1976319702
@@ -19883,6 +19822,7 @@ var Phaser;
1988319822 this._loadComplete = true;
1988419823 } else {
1988519824 // Start the loader going as we have something in the queue
19825+ this.load.onLoadComplete.add(this.loadComplete, this);
1988619826 this.load.start();
1988719827 }
1988819828 } else {
0 commit comments