Skip to content

Commit 4ad7b30

Browse files
committed
Added Game configuration option: forceSetTimeOut
1 parent f07c10e commit 4ad7b30

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

src/core/Game.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,15 @@ Phaser.Game.prototype = {
466466
this.isRunning = true;
467467
this._loadComplete = false;
468468

469-
this.raf = new Phaser.RequestAnimationFrame(this);
469+
if (this.config && this.config['forceSetTimeOut'])
470+
{
471+
this.raf = new Phaser.RequestAnimationFrame(this, this.config['forceSetTimeOut']);
472+
}
473+
else
474+
{
475+
this.raf = new Phaser.RequestAnimationFrame(this, false);
476+
}
477+
470478
this.raf.start();
471479
}
472480

src/gameobjects/Text.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
*/
66

77
/**
8-
* Create a new `Text` object.
8+
* Create a new `Text` object. This uses a local hidden Canvas object and renders the type into it. It then makes a texture from this for renderning to the view.
9+
* Because of this you can only display fonts that are currently loaded and available to the browser. It won't load the fonts for you.
10+
* Here is a compatibility table showing the available default fonts across different mobile browsers: http://www.jordanm.co.uk/tinytype
11+
*
912
* @class Phaser.Text
1013
* @constructor
1114
* @param {Phaser.Game} game - Current game instance.

src/system/RequestAnimationFrame.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
* @class Phaser.RequestAnimationFrame
1111
* @constructor
1212
* @param {Phaser.Game} game - A reference to the currently running game.
13+
* @param {boolean} [forceSetTimeOut=false] - Tell Phaser to use setTimeOut even if raf is available.
1314
*/
14-
Phaser.RequestAnimationFrame = function(game) {
15+
Phaser.RequestAnimationFrame = function(game, forceSetTimeOut) {
1516

17+
if (typeof forceSetTimeOut === 'undefined') { forceSetTimeOut = false; }
18+
1619
/**
1720
* @property {Phaser.Game} game - The currently running game.
1821
*/
@@ -24,6 +27,11 @@ Phaser.RequestAnimationFrame = function(game) {
2427
*/
2528
this.isRunning = false;
2629

30+
/**
31+
* @property {boolean} forceSetTimeOut - Tell Phaser to use setTimeOut even if raf is available.
32+
*/
33+
this.forceSetTimeOut = forceSetTimeOut;
34+
2735
var vendors = [
2836
'ms',
2937
'moz',
@@ -69,7 +77,7 @@ Phaser.RequestAnimationFrame.prototype = {
6977

7078
var _this = this;
7179

72-
if (!window.requestAnimationFrame)
80+
if (!window.requestAnimationFrame || this.forceSetTimeOut)
7381
{
7482
this._isSetTimeOut = true;
7583

0 commit comments

Comments
 (0)