@@ -27,29 +27,11 @@ Phaser.Stage = function (game, width, height) {
2727 // The Pixi Stage which is hooked to the renderer
2828 this . _stage = new PIXI . Stage ( 0x000000 , false ) ;
2929 this . _stage . name = '_stage_root' ;
30-
31- Phaser . Canvas . getOffset ( this . canvas , this . offset ) ;
32-
33- this . bounds = new Phaser . Rectangle ( this . offset . x , this . offset . y , this . game . width , this . game . height ) ;
34-
30+
3531 this . scaleMode = Phaser . StageScaleMode . NO_SCALE ;
3632 this . scale = new Phaser . StageScaleMode ( this . game , width , height ) ;
3733 this . aspectRatio = width / height ;
3834
39- var _this = this ;
40-
41- this . _onChange = function ( event ) {
42- return _this . visibilityChange ( event ) ;
43- }
44-
45- document . addEventListener ( 'visibilitychange' , this . _onChange , false ) ;
46- document . addEventListener ( 'webkitvisibilitychange' , this . _onChange , false ) ;
47- document . addEventListener ( 'pagehide' , this . _onChange , false ) ;
48- document . addEventListener ( 'pageshow' , this . _onChange , false ) ;
49-
50- window . onblur = this . _onChange ;
51- window . onfocus = this . _onChange ;
52-
5335} ;
5436
5537Phaser . Stage . prototype = {
@@ -60,6 +42,28 @@ Phaser.Stage.prototype = {
6042 bounds : null ,
6143 offset : null ,
6244
45+ boot : function ( ) {
46+
47+ Phaser . Canvas . getOffset ( this . canvas , this . offset ) ;
48+
49+ this . bounds = new Phaser . Rectangle ( this . offset . x , this . offset . y , this . game . width , this . game . height ) ;
50+
51+ var _this = this ;
52+
53+ this . _onChange = function ( event ) {
54+ return _this . visibilityChange ( event ) ;
55+ }
56+
57+ document . addEventListener ( 'visibilitychange' , this . _onChange , false ) ;
58+ document . addEventListener ( 'webkitvisibilitychange' , this . _onChange , false ) ;
59+ document . addEventListener ( 'pagehide' , this . _onChange , false ) ;
60+ document . addEventListener ( 'pageshow' , this . _onChange , false ) ;
61+
62+ window . onblur = this . _onChange ;
63+ window . onfocus = this . _onChange ;
64+
65+ } ,
66+
6367 /**
6468 * This method is called when the document visibility is changed.
6569 */
0 commit comments