Skip to content

Commit

Permalink
Merge pull request #1152 from videlais/patch-5
Browse files Browse the repository at this point in the history
CocoonJSApp 'onSuspended' and 'onActivated' events
  • Loading branch information
photonstorm committed Aug 30, 2014
2 parents bc71d61 + cccaa30 commit 258e9d2
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/core/Stage.js
Expand Up @@ -298,6 +298,18 @@ Phaser.Stage.prototype.checkVisibility = function () {

window.onblur = this._onChange;
window.onfocus = this._onChange;

var _this = this;

if(this.game.device.cocoonJSApp)
{
CocoonJS.App.onSuspended.addEventListener(function () {
Phaser.Stage.prototype.visibilityChange.call(_this, {type: "pause"});
});
CocoonJS.App.onActivated.addEventListener(function () {
Phaser.Stage.prototype.visibilityChange.call(_this, {type: "resume"});
});
}

};

Expand Down Expand Up @@ -328,7 +340,7 @@ Phaser.Stage.prototype.visibilityChange = function (event) {
return;
}

if (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden)
if (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden || event.type === "pause")
{
this.game.gamePaused(event);
}
Expand Down

0 comments on commit 258e9d2

Please sign in to comment.