From 4ad7b304c6cdf069b3221fdad7e9609198a467c4 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Thu, 20 Feb 2014 01:31:13 +0000 Subject: [PATCH] Added Game configuration option: forceSetTimeOut --- src/core/Game.js | 10 +++++++++- src/gameobjects/Text.js | 5 ++++- src/system/RequestAnimationFrame.js | 12 ++++++++++-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/core/Game.js b/src/core/Game.js index bad3c62d..2b1cf940 100644 --- a/src/core/Game.js +++ b/src/core/Game.js @@ -466,7 +466,15 @@ Phaser.Game.prototype = { this.isRunning = true; this._loadComplete = false; - this.raf = new Phaser.RequestAnimationFrame(this); + if (this.config && this.config['forceSetTimeOut']) + { + this.raf = new Phaser.RequestAnimationFrame(this, this.config['forceSetTimeOut']); + } + else + { + this.raf = new Phaser.RequestAnimationFrame(this, false); + } + this.raf.start(); } diff --git a/src/gameobjects/Text.js b/src/gameobjects/Text.js index e2c42af1..5aa0b423 100644 --- a/src/gameobjects/Text.js +++ b/src/gameobjects/Text.js @@ -5,7 +5,10 @@ */ /** -* Create a new `Text` object. +* 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. +* 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. +* Here is a compatibility table showing the available default fonts across different mobile browsers: http://www.jordanm.co.uk/tinytype +* * @class Phaser.Text * @constructor * @param {Phaser.Game} game - Current game instance. diff --git a/src/system/RequestAnimationFrame.js b/src/system/RequestAnimationFrame.js index f58dee81..86661635 100644 --- a/src/system/RequestAnimationFrame.js +++ b/src/system/RequestAnimationFrame.js @@ -10,9 +10,12 @@ * @class Phaser.RequestAnimationFrame * @constructor * @param {Phaser.Game} game - A reference to the currently running game. +* @param {boolean} [forceSetTimeOut=false] - Tell Phaser to use setTimeOut even if raf is available. */ -Phaser.RequestAnimationFrame = function(game) { +Phaser.RequestAnimationFrame = function(game, forceSetTimeOut) { + if (typeof forceSetTimeOut === 'undefined') { forceSetTimeOut = false; } + /** * @property {Phaser.Game} game - The currently running game. */ @@ -24,6 +27,11 @@ Phaser.RequestAnimationFrame = function(game) { */ this.isRunning = false; + /** + * @property {boolean} forceSetTimeOut - Tell Phaser to use setTimeOut even if raf is available. + */ + this.forceSetTimeOut = forceSetTimeOut; + var vendors = [ 'ms', 'moz', @@ -69,7 +77,7 @@ Phaser.RequestAnimationFrame.prototype = { var _this = this; - if (!window.requestAnimationFrame) + if (!window.requestAnimationFrame || this.forceSetTimeOut) { this._isSetTimeOut = true;