mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Game.onBlur and Game.onFocus events are now dispatched regardless if Stage.disableVisibilityChange is true or false, so you can respond to these events without your game automatically pausing or resuming (#911)
This commit is contained in:
parent
2916f0413f
commit
8c41f6cc10
3 changed files with 15 additions and 7 deletions
|
@ -76,6 +76,7 @@ Version 2.0.6 - "Jornhill" - -in development-
|
|||
* Loader.isLoading is set to false if the filelist size is zero.
|
||||
* Sound.externalNode has had the `input` property dropped from it, bringing it back in line with the AudioNode spec (thanks @villetou, #840)
|
||||
* The StateManager has a preRenderCallback option, which checks for a preRender function existing on the State, but it was never called. Have decided to add this in, so the core Game loop now calls state.preRender right before the renderer runs (thanks @AnderbergE #869)
|
||||
* Game.onBlur and Game.onFocus events are now dispatched regardless if Stage.disableVisibilityChange is true or false, so you can respond to these events without your game automatically pausing or resuming (#911)
|
||||
|
||||
### CocoonJS Specific Updates
|
||||
|
||||
|
|
|
@ -787,7 +787,10 @@ Phaser.Game.prototype = {
|
|||
|
||||
this.onBlur.dispatch(event);
|
||||
|
||||
this.gamePaused(event);
|
||||
if (!this.stage.disableVisibilityChange)
|
||||
{
|
||||
this.gamePaused(event);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
@ -802,7 +805,10 @@ Phaser.Game.prototype = {
|
|||
|
||||
this.onFocus.dispatch(event);
|
||||
|
||||
this.gameResumed(event);
|
||||
if (!this.stage.disableVisibilityChange)
|
||||
{
|
||||
this.gameResumed(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -287,16 +287,12 @@ Phaser.Stage.prototype.checkVisibility = function () {
|
|||
|
||||
/**
|
||||
* This method is called when the document visibility is changed.
|
||||
*
|
||||
* @method Phaser.Stage#visibilityChange
|
||||
* @param {Event} event - Its type will be used to decide whether the game should be paused or not.
|
||||
*/
|
||||
Phaser.Stage.prototype.visibilityChange = function (event) {
|
||||
|
||||
if (this.disableVisibilityChange)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.type === 'pagehide' || event.type === 'blur' || event.type === 'pageshow' || event.type === 'focus')
|
||||
{
|
||||
if (event.type === 'pagehide' || event.type === 'blur')
|
||||
|
@ -311,6 +307,11 @@ Phaser.Stage.prototype.visibilityChange = function (event) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.disableVisibilityChange)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (document.hidden || document.mozHidden || document.msHidden || document.webkitHidden)
|
||||
{
|
||||
this.game.gamePaused(event);
|
||||
|
|
Loading…
Reference in a new issue