Fixed Firefox audio issue with the Loader and added defined functions for anonymous callbacks

This commit is contained in:
Richard Davey
2013-08-05 03:43:20 +01:00
parent 84ef32e62a
commit d1da4cbdef
15 changed files with 314 additions and 200 deletions
+15 -4
View File
@@ -89,6 +89,11 @@ module Phaser {
**/
public isRunning: bool = false;
/**
* A reference to the RAF/setTimeout to avoid constant anonymous function creation
*/
public _onLoop;
/**
* Starts the requestAnimatioFrame running or setTimeout if unavailable in browser
* @method start
@@ -104,12 +109,14 @@ module Phaser {
if (!window.requestAnimationFrame)
{
this._isSetTimeOut = true;
this._timeOutID = window.setTimeout(() => this.SetTimeoutUpdate(), 0);
this._onLoop = () => this.SetTimeoutUpdate();
this._timeOutID = window.setTimeout(this._onLoop, 0);
}
else
{
this._isSetTimeOut = false;
window.requestAnimationFrame(() => this.RAFUpdate(0));
this._onLoop = () => this.RAFUpdate(0);
window.requestAnimationFrame(this._onLoop);
}
this.isRunning = true;
@@ -148,7 +155,9 @@ module Phaser {
this.callback.call(this._game);
}
window.requestAnimationFrame((time) => this.RAFUpdate(time));
this._onLoop = (time) => this.RAFUpdate(time);
window.requestAnimationFrame(this._onLoop);
}
@@ -160,7 +169,9 @@ module Phaser {
this._game.time.update(Date.now());
this._timeOutID = window.setTimeout(() => this.SetTimeoutUpdate(), 16.7);
this._onLoop = () => this.SetTimeoutUpdate();
this._timeOutID = window.setTimeout(this._onLoop, 16);
if (this.callback)
{