From c1872356fe42bd7f2c06cbf889245f857d9c97e3 Mon Sep 17 00:00:00 2001 From: Dan Cox Date: Fri, 29 Aug 2014 20:58:19 -0400 Subject: [PATCH 1/2] Detect CocoonJS.App There's a bit of a story behind this, but I'll try to keep it short. While I've been working on a patch to detect Cordova's 'pause' and 'resume' events for Phaser.Stage's checkVisibilityChange(), I came across this [thread] (http://www.html5gamedevs.com/topic/8834-cocoonjs-pause-game-on-app-switch/) over on the forum. My hope, at the time, was that someone else would come along and write this patch and I could use their work to finish my own code. But, since that hasn't happened yet (and might never), I'm sending in this PR first for the check that establishes a 'game.device.cocoonJSApp' boolean that I plan to use later. --- src/system/Device.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/system/Device.js b/src/system/Device.js index 74037e09d..cd0992148 100644 --- a/src/system/Device.js +++ b/src/system/Device.js @@ -38,6 +38,12 @@ Phaser.Device = function (game) { */ this.cocoonJS = false; + /** + * @property {boolean} cocoonJSApp - Is this game running with CocoonJS.App? + * @default + */ + this.cocoonJSApp = false; + /** * @property {boolean} cordova - Is the game running under Apache Cordova? * @default @@ -662,6 +668,15 @@ Phaser.Device.prototype = { { this.cocoonJS = true; } + + if(this.cocoonJS) + { + try { + this.cocoonJSApp = (typeof CocoonJS.App !== "undefined"); + } catch(error) { + this.cocoonJSApp = false; + } + } if (typeof window.ejecta !== "undefined") { From 3f7f6fac2c65afd997dce506341684e7e2de0864 Mon Sep 17 00:00:00 2001 From: Dan Cox Date: Fri, 29 Aug 2014 22:33:33 -0400 Subject: [PATCH 2/2] Adjustment for JSLint --- src/system/Device.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/system/Device.js b/src/system/Device.js index cd0992148..7c17709b1 100644 --- a/src/system/Device.js +++ b/src/system/Device.js @@ -672,7 +672,7 @@ Phaser.Device.prototype = { if(this.cocoonJS) { try { - this.cocoonJSApp = (typeof CocoonJS.App !== "undefined"); + this.cocoonJSApp = (typeof CocoonJS !== "undefined"); } catch(error) { this.cocoonJSApp = false; }