Skip to content

Commit 79e1350

Browse files
committed
ScaleManager.hasPhaserSetFullScreen is a new boolean that identifies if the browser is in full screen mode or not, and if Phaser was the one that requested it. As it's possible to enter full screen mode outside of Phaser, and it then gets confused about what bounding parent to use.
1 parent b90d7b2 commit 79e1350

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,12 +324,13 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
324324
* Group.align has had its arguments changed so that it's now `(width, height, ...)` instead of `(rows, columns, ...)` (thanks @deargle #2643)
325325
* Group.align now returns `true` if the Group was aligned, or `false` if not.
326326
* The Loader.headers object has a new property `requestedWith`. By default this is set to `false`, but it can be used to set the `X-Requested-With` header to `XMLHttpRequest` (or any other value you need). To enable this do `this.load.headers.requestedWith = 'XMLHttpRequest'` before adding anything to the Loader.
327+
* ScaleManager.hasPhaserSetFullScreen is a new boolean that identifies if the browser is in full screen mode or not, and if Phaser was the one that requested it. As it's possible to enter full screen mode outside of Phaser, and it then gets confused about what bounding parent to use.
327328

328329
### Bug Fixes
329330

330331
* A Group with `inputEnableChildren` set would re-start the Input Handler on a Sprite, even if that handler had been disabled previously.
331332
* Weapon.autofire wouldn't fire after the first bullet, or until `fire` was called, neither of which are requirements. If you now set this boolean the Weapon will fire continuously until you toggle it back to false (thanks @alverLopez #2647)
332-
*
333+
* ArcadePhysics.World.angleBetweenCenters now uses `centerX` and `centerY` properties to check for the angle between, instead of `center.x/y` as that property no longer exists (thanks @leopoldobrines7 #2654)
333334

334335
### Pixi Updates
335336

src/core/ScaleManager.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ Phaser.ScaleManager = function (game, width, height) {
220220
*/
221221
this.leaveIncorrectOrientation = new Phaser.Signal();
222222

223+
/**
224+
* This boolean provides you with a way to determine if the browser is in Full Screen
225+
* mode (via the Full Screen API), and Phaser was the one responsible for activating it.
226+
*
227+
* It's possible that ScaleManager.isFullScreen returns `true` even if Phaser wasn't the
228+
* one that made the browser go full-screen, so this flag lets you determine that.
229+
*
230+
* @property {boolean} hasPhaserSetFullScreen
231+
* @default
232+
*/
233+
this.hasPhaserSetFullScreen = false;
234+
223235
/**
224236
* If specified, this is the DOM element on which the Fullscreen API enter request will be invoked.
225237
* The target element must have the correct CSS styling and contain the Display canvas.
@@ -1760,9 +1772,11 @@ Phaser.ScaleManager.prototype = {
17601772
{
17611773
// Error is called in timeout to emulate the real fullscreenerror event better
17621774
var _this = this;
1775+
17631776
setTimeout(function () {
17641777
_this.fullScreenError();
17651778
}, 10);
1779+
17661780
return;
17671781
}
17681782

@@ -1779,7 +1793,7 @@ Phaser.ScaleManager.prototype = {
17791793
}
17801794
}
17811795

1782-
if (typeof antialias !== 'undefined' && this.game.renderType === Phaser.CANVAS)
1796+
if (antialias !== undefined && this.game.renderType === Phaser.CANVAS)
17831797
{
17841798
this.game.stage.smoothed = antialias;
17851799
}
@@ -1798,6 +1812,8 @@ Phaser.ScaleManager.prototype = {
17981812
targetElement: fsTarget
17991813
};
18001814

1815+
this.hasPhaserSetFullScreen = true;
1816+
18011817
this.onFullScreenInit.dispatch(this, initData);
18021818

18031819
if (this._createdFullScreenTarget)
@@ -1837,6 +1853,8 @@ Phaser.ScaleManager.prototype = {
18371853
return false;
18381854
}
18391855

1856+
this.hasPhaserSetFullScreen = false;
1857+
18401858
document[this.game.device.cancelFullscreen]();
18411859

18421860
return true;
@@ -2083,14 +2101,17 @@ Phaser.ScaleManager.prototype.constructor = Phaser.ScaleManager;
20832101
Object.defineProperty(Phaser.ScaleManager.prototype, "boundingParent", {
20842102

20852103
get: function () {
2104+
20862105
if (this.parentIsWindow ||
2087-
(this.isFullScreen && !this._createdFullScreenTarget))
2106+
(this.isFullScreen && this.hasPhaserSetFullScreen && !this._createdFullScreenTarget))
20882107
{
20892108
return null;
20902109
}
20912110

20922111
var parentNode = this.game.canvas && this.game.canvas.parentNode;
2112+
20932113
return parentNode || null;
2114+
20942115
}
20952116

20962117
});

typescript/phaser.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="pixi.d.ts" />
22
/// <reference path="p2.d.ts" />
33

4-
// Type definitions for Phaser 2.6.1 - 11th July 2016
4+
// Type definitions for Phaser 2.7.0 - 21st July 2016
55
// Project: https://github.com/photonstorm/phaser
66

77
declare module "phaser" {
@@ -4683,6 +4683,7 @@ declare module Phaser {
46834683
fullScreenTarget: HTMLElement;
46844684
game: Phaser.Game;
46854685
grid: Phaser.FlexGrid;
4686+
hasPhaserSetFullScreen: boolean;
46864687
height: number;
46874688
incorrectOrientation: boolean;
46884689
isFullScreen: boolean;

0 commit comments

Comments
 (0)