Phaser API Documentation

  Version: 
Filter
This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Core . Config

This is a beta release of our new docs system. Found an issue?
Please tell us about it in the #📖-newdocs-feedback channel on the Phaser Discord

Phaser . Core . Config

The active game configuration settings, parsed from a Phaser.Types.Core.GameConfig object.

Constructor:

new Config([GameConfig])

Parameters:

name type arguments description
GameConfig Phaser.Types.Core.GameConfig <optional>

The configuration object for your Phaser Game instance.

Since: 3.0.0
Source: src/core/Config.js (Line 18)

Members

<constant> antialias: boolean
Focus
Focus

Description:

When set to true, WebGL uses linear interpolation to draw scaled or rotated textures, giving a smooth appearance. When set to false, WebGL uses nearest-neighbor interpolation, giving a crisper appearance. false also disables antialiasing of the game canvas itself, if the browser supports it, when the game canvas is scaled.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 354)
Focus
Focus
<constant> antialiasGL: boolean
Focus
Focus

Description:

Sets the antialias property when the WebGL context is created. Setting this value does not impact any subsequent textures that are created, or the canvas style attributes.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 359)
Focus
Focus
<constant> audio: Phaser.Types.Core.AudioConfig
Focus
Focus

Description:

The Audio Configuration object.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 307)
Focus
Focus
<constant> autoCenter: Phaser.Scale.CenterType
Focus
Focus

Description:

Automatically center the canvas within the parent?

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 84)
Focus
Focus
<constant> autoFocus: boolean
Focus
Focus

Description:

If true the window will automatically be given focus immediately and on any future mousedown event.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 193)
Focus
Focus
<constant> autoRound: boolean
Focus
Focus

Description:

Automatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 79)
Focus
Focus
<constant> backgroundColor: Phaser.Display.Color
Focus
Focus

Description:

The background color of the game canvas. The default is black. This value is ignored if transparent is set to true.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 438)
Focus
Focus
<constant> bannerBackgroundColor: Array.<string>
Focus
Focus

Description:

The background colors of the banner.

Type:
Array.<string>
Since: 3.0.0
Source: src/core/Config.js (Line 329)
Focus
Focus
<constant> bannerTextColor: string
Focus
Focus

Description:

The color of the banner text.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 324)
Focus
Focus
<constant> batchSize: number
Focus
Focus

Description:

The default WebGL Batch size. Represents the number of quads that can be added to a single batch.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 421)
Focus
Focus
<constant, nullable> canvas: HTMLCanvasElement
Focus
Focus

Description:

Force Phaser to use your own Canvas element instead of creating one.

Type:
HTMLCanvasElement
Since: 3.0.0
Source: src/core/Config.js (Line 146)
Focus
Focus
<constant, nullable> canvasStyle: string
Focus
Focus

Description:

Optional CSS attributes to be set on the canvas object created by the renderer.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 156)
Focus
Focus
<constant> clearBeforeRender: boolean
Focus
Focus

Description:

Whether the game canvas will be cleared between each rendering frame. You can disable this if you have a full-screen background image or game object.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 396)
Focus
Focus
<constant, nullable> context: CanvasRenderingContext2D | WebGLRenderingContext
Focus
Focus

Description:

Force Phaser to use your own Canvas context instead of creating one.

Type:
CanvasRenderingContext2D | WebGLRenderingContext
Since: 3.0.0
Source: src/core/Config.js (Line 151)
Focus
Focus
<constant> customEnvironment: boolean
Focus
Focus

Description:

Is Phaser running under a custom (non-native web) environment? If so, set this to true to skip internal Feature detection. If true the renderType cannot be left as AUTO.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 161)
Focus
Focus
<constant> defaultImage: string
Focus
Focus

Description:

A base64 encoded PNG that will be used as the default blank texture.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 583)
Focus
Focus
<constant> defaultPhysicsSystem: boolean | string
Focus
Focus

Description:

The default physics system. It will be started for each scene. Either 'arcade', 'impact' or 'matter'.

Type:
boolean | string
Since: 3.0.0
Source: src/core/Config.js (Line 464)
Focus
Focus
<constant> defaultPlugins: any
Focus
Focus

Description:

The plugins installed into every Scene (in addition to CoreScene and Global).

Type:
any
Since: 3.0.0
Source: src/core/Config.js (Line 575)
Focus
Focus
<constant> desynchronized: boolean
Focus
Focus

Description:

When set to true it will create a desynchronized context for both 2D and WebGL. See https://developers.google.com/web/updates/2019/05/desynchronized for details.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 369)
Focus
Focus
<constant> disableContextMenu: boolean
Focus
Focus

Description:

Set to true to disable the right-click context menu.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 302)
Focus
Focus
<constant, nullable> domBehindCanvas: boolean
Focus
Focus

Description:

Should the DOM Container that is created (if dom.createContainer is true) be positioned behind (true) or over the top (false, the default) of the game canvas?

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 205)
Focus
Focus
<constant, nullable> domCreateContainer: boolean
Focus
Focus

Description:

Should the game create a div element to act as a DOM Container? Only enable if you're using DOM Element objects. You must provide a parent object if you use this feature.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 200)
Focus
Focus
<constant, nullable> domPointerEvents: string
Focus
Focus

Description:

The default pointerEvents attribute set on the DOM Container.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 210)
Focus
Focus
<constant> expandParent: boolean
Focus
Focus

Description:

Is the Scale Manager allowed to adjust the CSS height property of the parent to be 100%?

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 74)
Focus
Focus
<constant> failIfMajorPerformanceCaveat: boolean
Focus
Focus

Description:

Let the browser abort creating a WebGL context if it judges performance would be unacceptable.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 411)
Focus
Focus
<constant> fps: Phaser.Types.Core.FPSConfig
Focus
Focus

Description:

The Frame Rate Configuration object, as parsed by the Timestep class.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 339)
Focus
Focus
<constant, nullable> fullscreenTarget: HTMLElement | string
Focus
Focus

Description:

The DOM element that will be sent into full screen mode, or its id. If undefined Phaser will create its own div and insert the canvas into it when entering fullscreen mode.

Type:
HTMLElement | string
Since: 3.0.0
Source: src/core/Config.js (Line 94)
Focus
Focus
<constant> gameTitle: string
Focus
Focus

Description:

The title of the game.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 178)
Focus
Focus
<constant> gameURL: string
Focus
Focus

Description:

The URL of the game.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 183)
Focus
Focus
<constant> gameVersion: string
Focus
Focus

Description:

The version of the game.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 188)
Focus
Focus
<constant> height: number | string
Focus
Focus

Description:

The height of the underlying canvas, in pixels.

Type:
number | string
Since: 3.0.0
Source: src/core/Config.js (Line 54)
Focus
Focus
<constant> hideBanner: boolean
Focus
Focus

Description:

Don't write the banner line to the console.log.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 314)
Focus
Focus
<constant> hidePhaser: boolean
Focus
Focus

Description:

Omit Phaser's name and version from the banner.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 319)
Focus
Focus
<constant> inputActivePointers: number
Focus
Focus

Description:

The number of Pointer objects created by default. In a mouse-only, or non-multi touch game, you can leave this as 1.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 277)
Focus
Focus
<constant> inputGamepad: boolean
Focus
Focus

Description:

Enable the Gamepad Plugin. This can be disabled in games that don't need gamepad input.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 292)
Focus
Focus
<constant> inputGamepadEventTarget: *
Focus
Focus

Description:

The DOM Target to listen for gamepad events on. Defaults to window if not specified.

Type:
*
Since: 3.0.0
Source: src/core/Config.js (Line 297)
Focus
Focus
<constant> inputKeyboard: boolean
Focus
Focus

Description:

Enable the Keyboard Plugin. This can be disabled in games that don't need keyboard input.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 217)
Focus
Focus
<constant, nullable> inputKeyboardCapture: Array.<number>
Focus
Focus

Description:

preventDefault will be called on every non-modified key which has a key code in this array. By default, it is empty.

Type:
Array.<number>
Since: 3.0.0
Source: src/core/Config.js (Line 227)
Focus
Focus
<constant> inputKeyboardEventTarget: *
Focus
Focus

Description:

The DOM Target to listen for keyboard events on. Defaults to window if not specified.

Type:
*
Since: 3.0.0
Source: src/core/Config.js (Line 222)
Focus
Focus
<constant> inputMouse: boolean | object
Focus
Focus

Description:

Enable the Mouse Plugin. This can be disabled in games that don't need mouse input.

Type:
boolean | object
Since: 3.0.0
Source: src/core/Config.js (Line 232)
Focus
Focus
<constant, nullable> inputMouseEventTarget: *
Focus
Focus

Description:

The DOM Target to listen for mouse events on. Defaults to the game canvas if not specified.

Type:
*
Since: 3.0.0
Source: src/core/Config.js (Line 237)
Focus
Focus
<constant> inputMousePreventDefaultDown: boolean
Focus
Focus

Description:

Should mousedown DOM events have preventDefault called on them?

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 242)
Focus
Focus
<constant> inputMousePreventDefaultMove: boolean
Focus
Focus

Description:

Should mousemove DOM events have preventDefault called on them?

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 252)
Focus
Focus
<constant> inputMousePreventDefaultUp: boolean
Focus
Focus

Description:

Should mouseup DOM events have preventDefault called on them?

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 247)
Focus
Focus
<constant> inputMousePreventDefaultWheel: boolean
Focus
Focus

Description:

Should wheel DOM events have preventDefault called on them?

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 257)
Focus
Focus
<constant> inputSmoothFactor: number
Focus
Focus

Description:

The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 282)
Focus
Focus
<constant> inputTouch: boolean
Focus
Focus

Description:

Enable the Touch Plugin. This can be disabled in games that don't need touch input.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 262)
Focus
Focus
<constant> inputTouchCapture: boolean
Focus
Focus

Description:

Should touch events be captured? I.e. have prevent default called on them.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 272)
Focus
Focus
<constant, nullable> inputTouchEventTarget: *
Focus
Focus

Description:

The DOM Target to listen for touch events on. Defaults to the game canvas if not specified.

Type:
*
Since: 3.0.0
Source: src/core/Config.js (Line 267)
Focus
Focus
<constant> inputWindowEvents: boolean
Focus
Focus

Description:

Should Phaser listen for input events on the Window? If you disable this, events like 'POINTER_UP_OUTSIDE' will no longer fire.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 287)
Focus
Focus
<constant> installGlobalPlugins: any
Focus
Focus

Description:

An array of global plugins to be installed.

Type:
any
Since: 3.0.0
Source: src/core/Config.js (Line 539)
Focus
Focus
<constant> installScenePlugins: any
Focus
Focus

Description:

An array of Scene level plugins to be installed.

Type:
any
Since: 3.0.0
Source: src/core/Config.js (Line 544)
Focus
Focus
<constant> loaderAsync: boolean
Focus
Focus

Description:

Should the XHR request use async or not?

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 496)
Focus
Focus
<constant> loaderBaseURL: string
Focus
Focus

Description:

A URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 469)
Focus
Focus
<constant> loaderCrossOrigin: string | undefined
Focus
Focus

Description:

'anonymous', 'use-credentials', or undefined. If you're not making cross-origin requests, leave this as undefined. See {@link https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes}.

Type:
string | undefined
Since: 3.0.0
Source: src/core/Config.js (Line 486)
Focus
Focus
<constant> loaderMaxParallelDownloads: number
Focus
Focus

Description:

Maximum parallel downloads allowed for resources (Default to 32).

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 479)
Focus
Focus
<constant> loaderPassword: string
Focus
Focus

Description:

Optional password for all XHR requests.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 506)
Focus
Focus
<constant> loaderPath: string
Focus
Focus

Description:

A URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 474)
Focus
Focus
<constant> loaderResponseType: string
Focus
Focus

Description:

The response type of the XHR request, e.g. blob, text, etc.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 491)
Focus
Focus
<constant> loaderTimeout: number
Focus
Focus

Description:

Optional XHR timeout value, in ms.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 511)
Focus
Focus
<constant> loaderUser: string
Focus
Focus

Description:

Optional username for all XHR requests.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 501)
Focus
Focus
<constant> loaderWithCredentials: boolean
Focus
Focus

Description:

Optional XHR withCredentials value.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 516)
Focus
Focus
<constant> maxHeight: number
Focus
Focus

Description:

The maximum height, in pixels, the canvas will scale up to. A value of zero means no maximum.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 114)
Focus
Focus
<constant> maxLights: number
Focus
Focus

Description:

The maximum number of lights allowed to be visible within range of a single Camera in the LightManager.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 431)
Focus
Focus
<constant> maxTextures: number
Focus
Focus

Description:

When in WebGL mode, this sets the maximum number of GPU Textures to use. The default, -1, will use all available units. The WebGL1 spec says all browsers should provide a minimum of 8.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 426)
Focus
Focus
<constant> maxWidth: number
Focus
Focus

Description:

The maximum width, in pixels, the canvas will scale up to. A value of zero means no maximum.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 104)
Focus
Focus
<constant> minHeight: number
Focus
Focus

Description:

The minimum height, in pixels, the canvas will scale down to. A value of zero means no minimum.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 109)
Focus
Focus
<constant> minWidth: number
Focus
Focus

Description:

The minimum width, in pixels, the canvas will scale down to. A value of zero means no minimum.

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 99)
Focus
Focus
<constant> mipmapFilter: string
Focus
Focus

Description:

Sets the mipmapFilter property when the WebGL renderer is created.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 364)
Focus
Focus
<constant> missingImage: string
Focus
Focus

Description:

A base64 encoded PNG that will be used as the default texture when a texture is assigned that is missing or not loaded.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 588)
Focus
Focus
<constant, nullable> parent: *
Focus
Focus

Description:

A parent DOM element into which the canvas created by the renderer will be injected.

Type:
*
Since: 3.0.0
Source: src/core/Config.js (Line 64)
Focus
Focus
<constant> physics: Phaser.Types.Core.PhysicsConfig
Focus
Focus

Description:

The Physics Configuration object.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 459)
Focus
Focus
<constant> pipeline: Phaser.Types.Core.PipelineConfig
Focus
Focus

Description:

An object mapping WebGL names to WebGLPipeline classes. These should be class constructors, not instances.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 349)
Focus
Focus
<constant> pixelArt: boolean
Focus
Focus

Description:

Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a linear filter mode).

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 379)
Focus
Focus
<constant> postBoot: Phaser.Types.Core.BootCallback
Focus
Focus

Description:

A function to run at the end of the boot sequence. At this point, all the game systems have started and plugins have been loaded.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 454)
Focus
Focus
<constant> powerPreference: string
Focus
Focus

Description:

"high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 416)
Focus
Focus
<constant> preBoot: Phaser.Types.Core.BootCallback
Focus
Focus

Description:

Called before Phaser boots. Useful for initializing anything not related to Phaser that Phaser may require while booting.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 449)
Focus
Focus
<constant> premultipliedAlpha: boolean
Focus
Focus

Description:

In WebGL mode, sets the drawing buffer to contain colors with pre-multiplied alpha.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 406)
Focus
Focus
<constant> preserveDrawingBuffer: boolean
Focus
Focus

Description:

If the value is true the WebGL buffers will not be cleared and will preserve their values until cleared or overwritten by the author.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 401)
Focus
Focus
<constant> renderType: number
Focus
Focus

Description:

Force Phaser to use a specific renderer. Can be CONST.CANVAS, CONST.WEBGL, CONST.HEADLESS or CONST.AUTO (default)

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 141)
Focus
Focus
<constant> resizeInterval: number
Focus
Focus

Description:

How many ms should elapse before checking if the browser size has changed?

Type:
number
Since: 3.0.0
Source: src/core/Config.js (Line 89)
Focus
Focus
<constant> roundPixels: boolean
Focus
Focus

Description:

Draw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 374)
Focus
Focus
<constant> scaleMode: Phaser.Scale.ScaleModeType
Focus
Focus

Description:

The scale mode as used by the Scale Manager. The default is zero, which is no scaling.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 69)
Focus
Focus
<constant, nullable> sceneConfig: object
Focus
Focus

Description:

The default Scene configuration object.

Type:
object
Since: 3.0.0
Source: src/core/Config.js (Line 166)
Focus
Focus
<constant> seed: Array.<string>
Focus
Focus

Description:

A seed which the Random Data Generator will use. If not given, a dynamic seed based on the time is used.

Type:
Array.<string>
Since: 3.0.0
Source: src/core/Config.js (Line 171)
Focus
Focus
<constant> transparent: boolean
Focus
Focus

Description:

Whether the game canvas will have a transparent background.

Type:
boolean
Since: 3.0.0
Source: src/core/Config.js (Line 391)
Focus
Focus
<constant> whiteImage: string
Focus
Focus

Description:

A base64 encoded PNG that will be used as the default texture when a texture is assigned that is white or not loaded.

Type:
string
Since: 3.0.0
Source: src/core/Config.js (Line 593)
Focus
Focus
<constant> width: number | string
Focus
Focus

Description:

The width of the underlying canvas, in pixels.

Type:
number | string
Since: 3.0.0
Source: src/core/Config.js (Line 49)
Focus
Focus
<constant> zoom: number | Phaser.Scale.ZoomType
Focus
Focus

Description:

The zoom factor, as used by the Scale Manager.

Type:
Since: 3.0.0
Source: src/core/Config.js (Line 59)
Focus
Focus