Class: StageScaleMode

Phaser. StageScaleMode

Phaser.StageScaleMode

new StageScaleMode(game, width, height)

An Animation instance contains a single animation and the controls to play it. It is created by the AnimationManager, consists of Animation.Frame objects and belongs to a single Game Object such as a Sprite.

Parameters:
Name Type Description
game Phaser.Game

A reference to the currently running game.

width number

Description.

height number

Description.

Source:

Members

<static, constant> EXACT_FIT :number

Type:
  • number
Source:

<static, constant> NO_SCALE :number

Type:
  • number
Source:

<static, constant> SHOW_ALL :number

Type:
  • number
Source:

aspectRatio

Properties:
Name Type Description
aspectRatio number

Aspect ratio.

Default Value:
  • 0
Source:

enterLandscape

Properties:
Name Type Description
enterLandscape Phaser.Signal

The event that is dispatched when the browser enters landscape orientation.

Source:

enterPortrait

Properties:
Name Type Description
enterPortrait Phaser.Signal

The event that is dispatched when the browser enters horizontal orientation.

Source:

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:

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:

game

Properties:
Name Type Description
game Phaser.Game

A reference to the currently running game.

Source:

height

Properties:
Name Type Description
height number

Height of the stage after calculation.

Source:

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:

<readonly> isFullScreen

Properties:
Name Type Description
isFullScreen boolean

Returns true if the browser is in full screen mode, otherwise false.

Source:

<readonly> isLandscape

Properties:
Name Type Description
isLandscape boolean

Returns true if the browser dimensions match a landscape display.

Source:

<readonly> isPortrait

Properties:
Name Type Description
isPortrait boolean

Returns true if the browser dimensions match a portrait display.

Source:

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.

Default Value:
  • null
Source:

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:

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.

Default Value:
  • null
Source:

minHeight

Properties:
Name Type Description
minHeight number

Minimum height the canvas should be scaled to (in pixels).

Default Value:
  • null
Source:

minWidth

Properties:
Name Type Description
minWidth number

Minimum width the canvas should be scaled to (in pixels).

Default Value:
  • null
Source:

orientationSprite

Properties:
Name Type Description
orientationSprite PIXI.Sprite

The Sprite that is optionally displayed if the browser enters an unsupported orientation.

Default Value:
  • null
Source:

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:

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:

scaleFactor

Properties:
Name Type Description
scaleFactor Phaser.Point

The scale factor based on the game dimensions vs. the scaled dimensions.

Source:

width

Properties:
Name Type Description
width number

Width of the stage after calculation.

Source:

Methods

checkOrientation(event)

Handle window.orientationchange events

Parameters:
Name Type Description
event Event

The orientationchange event data.

Source:

checkOrientationState()

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

Source:

checkResize(event)

Handle window.resize events

Parameters:
Name Type Description
event Event

The resize event data.

Source:

forceOrientation(forceLandscape, forcePortrait, forcePortrait)

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

true if the game should run in portrait mode only.

forcePortrait string <optional>
''

The string of an image in the Phaser.Cache to display when this game is in the incorrect orientation.

Source:

<protected> fullScreenChange(event)

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

Parameters:
Name Type Description
event Event

The fullscreenchange event

Source:

refresh()

Re-calculate scale mode and update screen size.

Source:

setExactFit()

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

Source:

setMaximum()

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

Source:

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:

setShowAll()

Calculates the multiplier needed to scale the game proportionally.

Source:

setSize()

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

Source:

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:

stopFullScreen()

Stops full screen mode if the browser is in it.

Source:
Phaser Copyright © 2012-2013 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Thu Nov 07 2013 06:07:40 GMT-0000 (GMT) using the DocStrap template.