# Class: ScaleManager

## Phaser. ScaleManager

Phaser.ScaleManager

#### new ScaleManager(game, width, height)

  The ScaleManager object is responsible for helping you manage the scaling, resizing and alignment of your game within the browser.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | A reference to the currently running game.
  `width` | number | The native width of the game.
  `height` | number | The native height of the game.

  Source:
    - core/ScaleManager.js, line 16

### Members

#### <static, constant> EXACT_FIT :number

  ##### Type:

  - number
  Source:
    - core/ScaleManager.js, line 261

#### <static, constant> NO_SCALE :number

  ##### Type:

  - number
  Source:
    - core/ScaleManager.js, line 267

#### <static, constant> SHOW_ALL :number

  ##### Type:

  - number
  Source:
    - core/ScaleManager.js, line 273

#### <readonly> aspectRatio

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `aspectRatio` | number | The aspect ratio of the scaled game.

  Source:
    - core/ScaleManager.js, line 186

#### <readonly> bounds

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `bounds` | Phaser.Rectangle | The bounds of the scaled game. The x/y will match the offset of the canvas element and the width/height the scaled width and height.

  Source:
    - core/ScaleManager.js, line 180

#### enterFullScreen

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `enterFullScreen` | Phaser.Signal | The event that is dispatched when the browser enters full screen mode (if it supports the FullScreen API).

  Source:
    - core/ScaleManager.js, line 134

#### enterIncorrectOrientation

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `enterIncorrectOrientation` | Phaser.Signal | The event that is dispatched when the browser enters an incorrect orientation, as defined by forceOrientation.

  Source:
    - core/ScaleManager.js, line 111

#### enterLandscape

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `enterLandscape` | Phaser.Signal | The event that is dispatched when the browser enters landscape orientation.

  Source:
    - core/ScaleManager.js, line 101

#### enterPortrait

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `enterPortrait` | Phaser.Signal | The event that is dispatched when the browser enters horizontal orientation.

  Source:
    - core/ScaleManager.js, line 106

#### event

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `event-` | any | The native browser events from full screen API changes.

  Source:
    - core/ScaleManager.js, line 197

#### forceLandscape

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `forceLandscape` | boolean | If the game should be forced to use Landscape mode, this is set to true by Game.Stage

  Default Value:
    - false
  Source:
    - core/ScaleManager.js, line 57

#### forcePortrait

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `forcePortrait` | boolean | If the game should be forced to use Portrait mode, this is set to true by Game.Stage

  Default Value:
    - false
  Source:
    - core/ScaleManager.js, line 63

#### fullScreenTarget

  This is the DOM element that will have the Full Screen mode called on it. It defaults to the game canvas, but can be retargetted to any valid DOM element. If you adjust this property it's up to you to see it has the correct CSS applied, and that you have contained the game canvas correctly. Note that if you use a scale property of EXACT_FIT then fullScreenTarget will have its width and height style set to 100%.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `fullScreenTarget` | any |

  Source:
    - core/ScaleManager.js, line 129

#### game

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `game` | Phaser.Game | A reference to the currently running game.

  Source:
    - core/ScaleManager.js, line 21

#### hasResized

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `hasResized` | Phaser.Signal | The event that is dispatched when the game scale changes.

  Source:
    - core/ScaleManager.js, line 121

#### height

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `height` | number | Height of the stage after calculation.

  Source:
    - core/ScaleManager.js, line 31

#### incorrectOrientation

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `incorrectOrientation` | boolean | If the game should be forced to use a specific orientation and the device currently isn't in that orientation this is set to true.

  Default Value:
    - false
  Source:
    - core/ScaleManager.js, line 69

#### <readonly> isFullScreen

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `isFullScreen` | boolean | Returns true if the browser is in full screen mode, otherwise false.

  Source:
    - core/ScaleManager.js, line 767

#### <readonly> isLandscape

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `isLandscape` | boolean | Returns true if the browser dimensions match a landscape display.

  Source:
    - core/ScaleManager.js, line 795

#### <readonly> isPortrait

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `isPortrait` | boolean | Returns true if the browser dimensions match a portrait display.

  Source:
    - core/ScaleManager.js, line 782

#### leaveFullScreen

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `leaveFullScreen` | Phaser.Signal | The event that is dispatched when the browser leaves full screen mode (if it supports the FullScreen API).

  Source:
    - core/ScaleManager.js, line 139

#### leaveIncorrectOrientation

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `leaveIncorrectOrientation` | Phaser.Signal | The event that is dispatched when the browser leaves an incorrect orientation, as defined by forceOrientation.

  Source:
    - core/ScaleManager.js, line 116

#### <readonly> margin

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `margin` | Phaser.Point | If the game canvas is set to align by adjusting the margin, the margin calculation values are stored in this Point.

  Source:
    - core/ScaleManager.js, line 174

#### maxHeight

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `maxHeight` | number | Maximum height the canvas should be scaled to (in pixels). If null it will scale to whatever height the browser can handle.

  Source:
    - core/ScaleManager.js, line 51

#### maxIterations

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `maxIterations` | number | The maximum number of times it will try to resize the canvas to fill the browser.

  Default Value:
    - 5
  Source:
    - core/ScaleManager.js, line 91

#### maxWidth

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `maxWidth` | number | Maximum width the canvas should be scaled to (in pixels). If null it will scale to whatever width the browser can handle.

  Source:
    - core/ScaleManager.js, line 41

#### minHeight

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `minHeight` | number | Minimum height the canvas should be scaled to (in pixels).

  Source:
    - core/ScaleManager.js, line 46

#### minWidth

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `minWidth` | number | Minimum width the canvas should be scaled to (in pixels).

  Source:
    - core/ScaleManager.js, line 36

#### orientation

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `orientation` | number | The orientation value of the game (as defined by window.orientation if set). 90 = landscape. 0 = portrait.

  Source:
    - core/ScaleManager.js, line 144

#### orientationSprite

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `orientationSprite` | PIXI.Sprite | The Sprite that is optionally displayed if the browser enters an unsupported orientation.

  Source:
    - core/ScaleManager.js, line 96

#### pageAlignHorizontally

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pageAlignHorizontally` | boolean | If you wish to align your game in the middle of the page then you can set this value to true. It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.

  Default Value:
    - false
  Source:
    - core/ScaleManager.js, line 77

#### pageAlignVertically

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pageAlignVertically` | boolean | If you wish to align your game in the middle of the page then you can set this value to true. It will place a re-calculated margin-left pixel value onto the canvas element which is updated on orientation/resizing. It doesn't care about any other DOM element that may be on the page, it literally just sets the margin.

  Default Value:
    - false
  Source:
    - core/ScaleManager.js, line 85

#### <readonly> scaleFactor

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `scaleFactor` | Phaser.Point | The scale factor based on the game dimensions vs. the scaled dimensions.

  Source:
    - core/ScaleManager.js, line 162

#### <readonly> scaleFactorInversed

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `scaleFactorInversed` | Phaser.Point | The inversed scale factor. The displayed dimensions divided by the game dimensions.

  Source:
    - core/ScaleManager.js, line 168

#### scaleMode

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `scaleMode` | number | The current scaleMode.

  Source:
    - core/ScaleManager.js, line 202

#### <readonly> sourceAspectRatio

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `sourceAspectRatio` | number | The aspect ratio (width / height) of the original game dimensions.

  Source:
    - core/ScaleManager.js, line 192

#### width

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `width` | number | Width of the stage after calculation.

  Source:
    - core/ScaleManager.js, line 26

### Methods

#### checkOrientation(event)

  Handle window.orientationchange events

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `event` | Event | The orientationchange event data.

  Source:
    - core/ScaleManager.js, line 466

#### checkOrientationState()

  Checks if the browser is in the correct orientation for your game (if forceLandscape or forcePortrait have been set)

  Source:
    - core/ScaleManager.js, line 417

#### checkResize(event)

  Handle window.resize events

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `event` | Event | The resize event data.

  Source:
    - core/ScaleManager.js, line 493

#### forceOrientation(forceLandscape, forcePortrait, orientationImage)

  If you need your game to run in only one orientation you can force that to happen. The optional orientationImage is displayed when the game is in the incorrect orientation.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `forceLandscape` | boolean |  |  | true if the game should run in landscape mode only.
  `forcePortrait` | boolean | <optional> | false | true if the game should run in portrait mode only.
  `orientationImage` | string | <optional> | '' | The string of an image in the Phaser.Cache to display when this game is in the incorrect orientation.

  Source:
    - core/ScaleManager.js, line 374

#### <protected> fullScreenChange(event)

  Called automatically when the browser enters of leaves full screen mode.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `event` | Event | The fullscreenchange event

  Source:
    - core/ScaleManager.js, line 319

#### refresh()

  Re-calculate scale mode and update screen size.

  Source:
    - core/ScaleManager.js, line 529

#### setExactFit()

  Sets the width and height values of the canvas, no larger than the maxWidth/Height.

  Source:
    - core/ScaleManager.js, line 734

#### setMaximum()

  Sets this.width equal to window.innerWidth and this.height equal to window.innerHeight

  Source:
    - core/ScaleManager.js, line 710

#### setScreenSize(force)

  Set screen size automatically based on the scaleMode.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `force` | boolean | If force is true it will try to resize the game regardless of the document dimensions.

  Source:
    - core/ScaleManager.js, line 570

#### setShowAll()

  Calculates the multiplier needed to scale the game proportionally.

  Source:
    - core/ScaleManager.js, line 721

#### setSize()

  Sets the canvas style width and height values based on minWidth/Height and maxWidth/Height.

  Source:
    - core/ScaleManager.js, line 630

#### startFullScreen(antialias)

  Tries to enter the browser into full screen mode. Please note that this needs to be supported by the web browser and isn't the same thing as setting your game to fill the browser.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `antialias` | boolean | You can toggle the anti-alias feature of the canvas before jumping in to full screen (false = retain pixel art, true = smooth art)

  Source:
    - core/ScaleManager.js, line 277

#### stopFullScreen()

  Stops full screen mode if the browser is in it.

  Source:
    - core/ScaleManager.js, line 309