New filters and demos: LightBeams, Fire and Tunnel. Also Loader can now load script files.

This commit is contained in:
photonstorm
2013-11-28 05:43:35 +00:00
parent 39025c1c2a
commit 780b8a5d6d
22 changed files with 546 additions and 13 deletions
+29
View File
@@ -110,6 +110,9 @@ Phaser.StateManager.prototype = {
*/
boot: function () {
this.game.onPause.add(this.pause, this);
this.game.onResume.add(this.resume, this);
if (this._pendingState !== null)
{
if (typeof this._pendingState === 'string')
@@ -392,6 +395,32 @@ Phaser.StateManager.prototype = {
},
/**
* @method Phaser.StateManager#pause
* @protected
*/
pause: function () {
if (this._created && this.onPausedCallback)
{
this.onPausedCallback.call(this.callbackContext, this.game, true);
}
},
/**
* @method Phaser.StateManager#resume
* @protected
*/
resume: function () {
if (this._created && this.onre)
{
this.onPausedCallback.call(this.callbackContext, this.game, false);
}
},
/**
* @method Phaser.StateManager#update
* @protected
+37
View File
@@ -345,6 +345,21 @@ Phaser.Loader.prototype = {
},
/**
* Add a JavaScript file to the Loader. Once loaded the JavaScript file will be automatically turned into a script tag (and executed), so be careful what you load!
*
* @method Phaser.Loader#script
* @param {string} key - Unique asset key of the script file.
* @param {string} url - URL of the JavaScript file.
*/
script: function (key, url) {
this.addToFileList('script', key, url);
return this;
},
/**
* Add a new sprite sheet to the loader.
*
@@ -824,6 +839,19 @@ Phaser.Loader.prototype = {
};
this._xhr.send();
break;
case 'script':
this._xhr.open("GET", this.baseURL + file.url, true);
this._xhr.responseType = "text";
this._xhr.onload = function () {
return _this.fileComplete(_this._fileIndex);
};
this._xhr.onerror = function () {
return _this.fileError(_this._fileIndex);
};
this._xhr.send();
break;
}
},
@@ -1007,6 +1035,15 @@ Phaser.Loader.prototype = {
file.data = this._xhr.responseText;
this.game.cache.addText(file.key, file.url, file.data);
break;
case 'script':
file.data = document.createElement('script');
file.data.language = 'javascript';
file.data.type = 'text/javascript';
file.data.defer = true;
file.data.text = this._xhr.responseText;
document.head.appendChild(file.data);
break;
}
if (loadNext)