@@ -189,24 +189,42 @@ Phaser.ScaleManager = function (game, width, height) {
189189 * @property {number } sourceAspectRatio - The aspect ratio (width / height) of the original game dimensions.
190190 * @readonly
191191 */
192- // this.sourceAspectRatio = width / height;
193192 this . sourceAspectRatio = 0 ;
194193
195194 /**
196195 * @property {any } event- The native browser events from full screen API changes.
197196 */
198197 this . event = null ;
199198
200- /**
201- * @property {number } scaleMode - The current scaleMode.
202- */
203- this . scaleMode = Phaser . ScaleManager . NO_SCALE ;
204-
205199 /*
206200 * @property {number } fullScreenScaleMode - Scale mode to be used in fullScreen
207201 */
208202 this . fullScreenScaleMode = Phaser . ScaleManager . NO_SCALE ;
209203
204+ /**
205+ * @property {boolean } parentIsWindow - If the parent container of the game is the browser window, rather than a div, this is set to `true`.
206+ * @readonly
207+ */
208+ this . parentIsWindow = false ;
209+
210+ /**
211+ * @property {object } parentNode - The fully parsed parent container of the game. If the parent is the browser window this will be `null`.
212+ * @readonly
213+ */
214+ this . parentNode = null ;
215+
216+ /**
217+ * @property {Phaser.Point } parentScaleFactor - The scale of the game in relation to its parent container.
218+ * @readonly
219+ */
220+ this . parentScaleFactor = new Phaser . Point ( 1 , 1 ) ;
221+
222+ /**
223+ * @property {number } scaleMode - The current scaling method being used.
224+ * @private
225+ */
226+ this . _scaleMode = Phaser . ScaleManager . NO_SCALE ;
227+
210228 /**
211229 * @property {number } _startHeight - Internal cache var. Stage height when starting the game.
212230 * @private
@@ -321,13 +339,21 @@ Phaser.ScaleManager.prototype = {
321339 {
322340 // Use the full window
323341 console . log ( 'target failed, using window' ) ;
342+
343+ this . parentNode = null ;
344+ this . parentIsWindow = true ;
345+
324346 rect . width = window . innerWidth ;
325347 rect . height = window . innerHeight ;
326348 }
327349 else
328350 {
329351 console . log ( 'target found, getting rect' ) ;
330352 console . log ( target . getBoundingClientRect ( ) ) ;
353+
354+ this . parentNode = target ;
355+ this . parentIsWindow = false ;
356+
331357 rect . width = target . getBoundingClientRect ( ) . width ;
332358 rect . height = target . getBoundingClientRect ( ) . height ;
333359 }
@@ -339,7 +365,8 @@ Phaser.ScaleManager.prototype = {
339365 else
340366 {
341367 // Percentage based
342- this . width = rect . width * ( parseInt ( width , 10 ) / 100 ) ;
368+ this . parentScaleFactor . x = parseInt ( width , 10 ) / 100 ;
369+ this . width = rect . width * this . parentScaleFactor . x ;
343370 }
344371
345372 if ( typeof height === 'number' )
@@ -349,7 +376,8 @@ Phaser.ScaleManager.prototype = {
349376 else
350377 {
351378 // Percentage based
352- this . height = rect . height * ( parseInt ( height , 10 ) / 100 ) ;
379+ this . parentScaleFactor . y = parseInt ( height , 10 ) / 100 ;
380+ this . height = rect . height * this . parentScaleFactor . y ;
353381 }
354382
355383 this . game . width = this . width ;
@@ -874,6 +902,31 @@ Phaser.ScaleManager.prototype = {
874902
875903Phaser . ScaleManager . prototype . constructor = Phaser . ScaleManager ;
876904
905+ /**
906+ * @name Phaser.ScaleManager#scaleMode
907+ * @property {number } scaleMode - The scaling method used by the ScaleManager.
908+ */
909+ Object . defineProperty ( Phaser . ScaleManager . prototype , "scaleMode" , {
910+
911+ get : function ( ) {
912+
913+ return this . _scaleMode ;
914+
915+ } ,
916+
917+ set : function ( value ) {
918+
919+ if ( value !== this . _scaleMode )
920+ {
921+ console . log ( 'new scale mode set' , value ) ;
922+ this . _scaleMode = value ;
923+ // Do stuff here like set-up tracking, etc
924+ }
925+
926+ }
927+
928+ } ) ;
929+
877930/**
878931* @name Phaser.ScaleManager#isFullScreen
879932* @property {boolean } isFullScreen - Returns true if the browser is in full screen mode, otherwise false.
0 commit comments