Skip to content

Commit 258e9d2

Browse files
committed
Merge pull request phaserjs#1152 from videlais/patch-5
CocoonJSApp 'onSuspended' and 'onActivated' events
2 parents bc71d61 + cccaa30 commit 258e9d2

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

src/core/Stage.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,18 @@ Phaser.Stage.prototype.checkVisibility = function () {
298298

299299
window.onblur = this._onChange;
300300
window.onfocus = this._onChange;
301+
302+
var _this = this;
303+
304+
if(this.game.device.cocoonJSApp)
305+
{
306+
CocoonJS.App.onSuspended.addEventListener(function () {
307+
Phaser.Stage.prototype.visibilityChange.call(_this, {type: "pause"});
308+
});
309+
CocoonJS.App.onActivated.addEventListener(function () {
310+
Phaser.Stage.prototype.visibilityChange.call(_this, {type: "resume"});
311+
});
312+
}
301313

302314
};
303315

@@ -328,7 +340,7 @@ Phaser.Stage.prototype.visibilityChange = function (event) {
328340
return;
329341
}
330342

331-
if (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden)
343+
if (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden || event.type === "pause")
332344
{
333345
this.game.gamePaused(event);
334346
}

0 commit comments

Comments
 (0)