Skip to content

Commit 2638e59

Browse files
committed
Added Stage.disablePauseScreen
1 parent 361b8e5 commit 2638e59

5 files changed

Lines changed: 55 additions & 42 deletions

File tree

Phaser/Stage.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ module Phaser {
6262
public clear: bool = true;
6363
public canvas: HTMLCanvasElement;
6464
public context: CanvasRenderingContext2D;
65+
public disablePauseScreen: bool = false;
6566
public offset: Point;
6667
public scale: StageScaleMode;
6768
public scaleMode: number;
@@ -92,8 +93,14 @@ module Phaser {
9293

9394
}
9495

96+
//if (document['hidden'] === true || document['webkitHidden'] === true)
9597
private visibilityChange(event) {
9698

99+
if (this.disablePauseScreen)
100+
{
101+
return;
102+
}
103+
97104
if (event.type == 'blur' && this._game.paused == false && this._game.isBooted == true)
98105
{
99106
this._game.paused = true;
@@ -104,8 +111,6 @@ module Phaser {
104111
this._game.paused = false;
105112
}
106113

107-
//if (document['hidden'] === true || document['webkitHidden'] === true)
108-
109114
}
110115

111116
public drawInitScreen() {

README.md

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,57 +20,57 @@ Change Log
2020

2121
V0.9.2
2222

23-
Fixed issue with create not being called if there was an empty init method.<br />
24-
Added ability to flip a sprite (Sprite.flipped = true) + a test case for it.<br />
25-
Added ability to restart a sprite animation.<br />
26-
Sprite animations don't restart if you call play on them when they are already running.<br />
23+
* Fixed issue with create not being called if there was an empty init method.
24+
* Added ability to flip a sprite (Sprite.flipped = true) + a test case for it.
25+
* Added ability to restart a sprite animation.
26+
* Sprite animations don't restart if you call play on them when they are already running.
27+
* Added Stage.disablePauseScreen. Set to true to stop your game pausing when the tab loses focus.
2728

2829
V0.9.1
2930

30-
Added the new align property to GameObjects that controls placement when rendering.<br />
31-
Added an align example to the Sprites test group (click the mouse to change alignment position)<br />
32-
Added a new MicroPoint class. Same as Point but much smaller / less functions, updated GameObject to use it.<br />
33-
Completely rebuilt the Rectangle class to use MicroPoints and store the values of the 9 points around the edges, to be used
34-
for new collision system.<br />
35-
Game.Input now has 2 signals you can subscribe to for down/up events, see the Sprite align example for use.<br />
36-
Updated the States examples to bring in-line with 0.9 release.
31+
* Added the new align property to GameObjects that controls placement when rendering.
32+
* Added an align example to the Sprites test group (click the mouse to change alignment position)
33+
* Added a new MicroPoint class. Same as Point but much smaller / less functions, updated GameObject to use it.
34+
* Completely rebuilt the Rectangle class to use MicroPoints and store the values of the 9 points around the edges, to be used
35+
for new collision system.
36+
* Game.Input now has 2 signals you can subscribe to for down/up events, see the Sprite align example for use.
37+
* Updated the States examples to bring in-line with 0.9 release.
3738

3839
V0.9
3940

40-
Large refactoring. Everything now lives inside the Phaser module, so all code and all tests have been updated to reflect this. Makes coding a tiny bit
41-
more verbose but stops the framework from globbing up the global namespace. Also should make code-insight work in WebStorm and similar editors.<br />
42-
Added the new GeomSprite object. This is a sprite that uses a geometry class for display (Circle, Rectangle, Point, Line). It's extremely flexible!<br />
43-
Added Geometry intersection results objects.<br />
44-
Added new Collision class and moved some functions there. Contains all the Game Object and Geometry Intersection methods.<br />
45-
Can now create a sprite animation based on frame names rather than indexes. Useful when you've an animation inside a texture atlas. Added test to show.<br />
46-
Added addKeyCapture(), removeKeyCapture() and clearCaptures() to Input.Keyboard. Calls event.preventDefault() on any keycode set to capture, allowing you to avoid page scrolling when using the cursor keys in a game for example.<br />
47-
Added new Motion class which contains lots of handy functions like 'moveTowardsObject', 'velocityFromAngle' and more.<br />
48-
Tween Manager added. You can now create tweens via Game.createTween (or for more control game.tweens). All the usual suspects are here: Bounce, Elastic, Quintic, etc and it's hooked into the core game clock, so if your game pauses and resumes your tweens adjust accordingly.
41+
* Large refactoring. Everything now lives inside the Phaser module, so all code and all tests have been updated to reflect this. Makes coding a tiny bit more verbose but stops the framework from globbing up the global namespace. Also should make code-insight work in WebStorm and similar editors.
42+
* Added the new GeomSprite object. This is a sprite that uses a geometry class for display (Circle, Rectangle, Point, Line). It's extremely flexible!
43+
* Added Geometry intersection results objects.
44+
* Added new Collision class and moved some functions there. Contains all the Game Object and Geometry Intersection methods.
45+
* Can now create a sprite animation based on frame names rather than indexes. Useful when you've an animation inside a texture atlas. Added test to show.
46+
* Added addKeyCapture(), removeKeyCapture() and clearCaptures() to Input.Keyboard. Calls event.preventDefault() on any keycode set to capture, allowing you to avoid page scrolling when using the cursor keys in a game for example.
47+
* Added new Motion class which contains lots of handy functions like 'moveTowardsObject', 'velocityFromAngle' and more.
48+
* Tween Manager added. You can now create tweens via Game.createTween (or for more control game.tweens). All the usual suspects are here: Bounce, * Elastic, Quintic, etc and it's hooked into the core game clock, so if your game pauses and resumes your tweens adjust accordingly.
4949

5050
V0.8
5151

52-
Added ability to set Sprite frame by name (sprite.frameName), useful when you've loaded a Texture Atlas with filename values set rather than using frame indexes.<br />
53-
Updated texture atlas 4 demo to show this.<br />
54-
Fixed a bug that would cause a run-time error if you tried to create a sprite using an invalid texture key.<br />
55-
Added in DynamicTexture support and a test case for it.<br />
52+
* Added ability to set Sprite frame by name (sprite.frameName), useful when you've loaded a Texture Atlas with filename values set rather than using frame indexes.
53+
* Updated texture atlas 4 demo to show this.
54+
* Fixed a bug that would cause a run-time error if you tried to create a sprite using an invalid texture key.
55+
* Added in DynamicTexture support and a test case for it.
5656

5757
V0.7
5858

59-
Renamed FullScreen to StageScaleMode as it's much more fitting. Tested across Android and iOS with the various scale modes.<br />
60-
Added in world x/y coordinates to the input class, and the ability to get world x/y input coordinates from any Camera.<br />
61-
Added the RandomDataGenerator for seeded random number generation.<br />
62-
Setting the game world size now resizes the default camera (optional bool flag)
59+
* Renamed FullScreen to StageScaleMode as it's much more fitting. Tested across Android and iOS with the various scale modes.
60+
* Added in world x/y coordinates to the input class, and the ability to get world x/y input coordinates from any Camera.
61+
* Added the RandomDataGenerator for seeded random number generation.
62+
* Setting the game world size now resizes the default camera (optional bool flag)
6363

6464
V0.6
6565

66-
Added in Touch support for mobile devices (and desktops that enable it) and populated x/y coords in Input with common values from touch and mouse.<br />
67-
Added new Circle geometry class (used by Touch) and moved them into a Geom folder.<br />
68-
Added in Device class for device inspection.<br />
69-
Added FullScreen class to enable full-screen support on mobile devices (scrolls URL bar out of the way on iOS and Android)
66+
* Added in Touch support for mobile devices (and desktops that enable it) and populated x/y coords in Input with common values from touch and mouse.
67+
* Added new Circle geometry class (used by Touch) and moved them into a Geom folder.
68+
* Added in Device class for device inspection.
69+
* Added FullScreen class to enable full-screen support on mobile devices (scrolls URL bar out of the way on iOS and Android)
7070

7171
V0.5
7272

73-
Initial release
73+
* Initial release
7474

7575
Requirements
7676
------------

Tests/phaser.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7384,6 +7384,7 @@ var Phaser;
73847384
function Stage(game, parent, width, height) {
73857385
var _this = this;
73867386
this.clear = true;
7387+
this.disablePauseScreen = false;
73877388
this.minScaleX = null;
73887389
this.maxScaleX = null;
73897390
this.minScaleY = null;
@@ -7432,15 +7433,18 @@ var Phaser;
74327433
this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 10, 40);
74337434
this.context.fillText('x: ' + this.x + ' y: ' + this.y, 10, 60);
74347435
};
7435-
Stage.prototype.visibilityChange = function (event) {
7436+
Stage.prototype.visibilityChange = //if (document['hidden'] === true || document['webkitHidden'] === true)
7437+
function (event) {
7438+
if(this.disablePauseScreen) {
7439+
return;
7440+
}
74367441
if(event.type == 'blur' && this._game.paused == false && this._game.isBooted == true) {
74377442
this._game.paused = true;
74387443
this.drawPauseScreen();
74397444
} else if(event.type == 'focus') {
74407445
this._game.paused = false;
74417446
}
7442-
//if (document['hidden'] === true || document['webkitHidden'] === true)
7443-
};
7447+
};
74447448
Stage.prototype.drawInitScreen = function () {
74457449
this.context.fillStyle = 'rgb(40, 40, 40)';
74467450
this.context.fillRect(0, 0, this.width, this.height);

build/phaser-092.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7384,6 +7384,7 @@ var Phaser;
73847384
function Stage(game, parent, width, height) {
73857385
var _this = this;
73867386
this.clear = true;
7387+
this.disablePauseScreen = false;
73877388
this.minScaleX = null;
73887389
this.maxScaleX = null;
73897390
this.minScaleY = null;
@@ -7432,15 +7433,18 @@ var Phaser;
74327433
this.context.fillText('Game Size: ' + this.width + ' x ' + this.height, 10, 40);
74337434
this.context.fillText('x: ' + this.x + ' y: ' + this.y, 10, 60);
74347435
};
7435-
Stage.prototype.visibilityChange = function (event) {
7436+
Stage.prototype.visibilityChange = //if (document['hidden'] === true || document['webkitHidden'] === true)
7437+
function (event) {
7438+
if(this.disablePauseScreen) {
7439+
return;
7440+
}
74367441
if(event.type == 'blur' && this._game.paused == false && this._game.isBooted == true) {
74377442
this._game.paused = true;
74387443
this.drawPauseScreen();
74397444
} else if(event.type == 'focus') {
74407445
this._game.paused = false;
74417446
}
7442-
//if (document['hidden'] === true || document['webkitHidden'] === true)
7443-
};
7447+
};
74447448
Stage.prototype.drawInitScreen = function () {
74457449
this.context.fillStyle = 'rgb(40, 40, 40)';
74467450
this.context.fillRect(0, 0, this.width, this.height);

build/phaser-092.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)