Skip to main content
Version: Phaser v4.0.0

Config

The active game configuration settings, parsed from a Phaser.Types.Core.GameConfig object. This class takes the raw configuration object passed to new Phaser.Game() and resolves all values, applying defaults where properties are not specified. The resulting Config instance is read-only and available via game.config. It controls fundamental aspects of the game including canvas dimensions, renderer type, physics settings, audio configuration, and plugin loading.

Constructor

new Config([GameConfig])

Parameters

nametypeoptionaldescription
GameConfigPhaser.Types.Core.GameConfigYesThe configuration object for your Phaser Game instance.

Scope: static

Source: src/core/Config.js#L18
Since: 3.0.0

Constants:

Public Members

antialias

antialias: boolean

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.

Source: src/core/Config.js#L354


antialiasGL

antialiasGL: boolean

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.

Source: src/core/Config.js#L359


audio

audio: Phaser.Types.Core.AudioConfig

Description:

The Audio Configuration object.

Source: src/core/Config.js#L308


autoCenter

autoCenter: Phaser.Scale.CenterType

Description:

Automatically center the canvas within the parent?

Source: src/core/Config.js#L90


autoFocus

autoFocus: boolean

Description:

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

Source: src/core/Config.js#L187


autoMobileTextures

autoMobileTextures: boolean

Description:

If iOS or Android detected, automatically restrict WebGL to use 1 texture per batch. This can help performance on some devices.

Source: src/core/Config.js#L349


autoRound

autoRound: boolean

Description:

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

Source: src/core/Config.js#L85


backgroundColor

backgroundColor: Phaser.Display.Color

Description:

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

Source: src/core/Config.js#L470


bannerBackgroundColor

bannerBackgroundColor: Array.<string>

Description:

The background colors of the banner.

Source: src/core/Config.js#L330


bannerTextColor

bannerTextColor: string

Description:

The color of the banner text.

Source: src/core/Config.js#L325


batchSize

batchSize: number

Description:

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

Source: src/core/Config.js#L448


canvas

canvas: HTMLCanvasElement

Description:

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

Source: src/core/Config.js#L140


canvasStyle

canvasStyle: string

Description:

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

Source: src/core/Config.js#L150


clearBeforeRender

clearBeforeRender: boolean

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.

Source: src/core/Config.js#L418


context

context: CanvasRenderingContext2D, WebGLRenderingContext

Description:

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

Source: src/core/Config.js#L145


customEnvironment

customEnvironment: boolean

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.

Source: src/core/Config.js#L155


defaultImage

defaultImage: string

Description:

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

Source: src/core/Config.js#L641


defaultPhysicsSystem

defaultPhysicsSystem: boolean, string

Description:

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

Source: src/core/Config.js#L496


defaultPlugins

defaultPlugins: any

Description:

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

Source: src/core/Config.js#L633


desynchronized

desynchronized: boolean

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.

Source: src/core/Config.js#L369


disableContextMenu

disableContextMenu: boolean

Description:

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

Source: src/core/Config.js#L303


domCreateContainer

domCreateContainer: boolean

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.

Source: src/core/Config.js#L206


domPointerEvents

domPointerEvents: string

Description:

The default pointerEvents attribute set on the DOM Container.

Source: src/core/Config.js#L211


expandParent

expandParent: boolean

Description:

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

Source: src/core/Config.js#L80


failIfMajorPerformanceCaveat

failIfMajorPerformanceCaveat: boolean

Description:

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

Source: src/core/Config.js#L438


fps

fps: Phaser.Types.Core.FPSConfig

Description:

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

Source: src/core/Config.js#L340


fullscreenTarget

fullscreenTarget: HTMLElement, string

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.

Source: src/core/Config.js#L100


gameTitle

gameTitle: string

Description:

The title of the game.

Source: src/core/Config.js#L172


gameURL

gameURL: string

Description:

The URL of the game.

Source: src/core/Config.js#L177


gameVersion

gameVersion: string

Description:

The version of the game.

Source: src/core/Config.js#L182


glowDistance

glowDistance: number

Description:

The distance of the Glow filter (defaults to 10)

Source: src/core/Config.js#L574


glowQuality

glowQuality: number

Description:

The quality of the Glow filter (defaults to 10)

Source: src/core/Config.js#L569


height

height: number, string

Description:

The height of the underlying canvas, in pixels.

Source: src/core/Config.js#L60


hideBanner

hideBanner: boolean

Description:

Don't write the banner line to the console.log. See Phaser.Types.Core.BannerConfig for details of this object.

Source: src/core/Config.js#L315


hidePhaser

hidePhaser: boolean

Description:

Omit Phaser's name and version from the banner.

Source: src/core/Config.js#L320


inputActivePointers

inputActivePointers: number

Description:

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

Source: src/core/Config.js#L278


inputGamepad

inputGamepad: boolean

Description:

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

Source: src/core/Config.js#L293


inputGamepadEventTarget

inputGamepadEventTarget: *

Description:

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

Source: src/core/Config.js#L298


inputKeyboard

inputKeyboard: boolean

Description:

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

Source: src/core/Config.js#L218


inputKeyboardCapture

inputKeyboardCapture: Array.<number>

Description:

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

Source: src/core/Config.js#L228


inputKeyboardEventTarget

inputKeyboardEventTarget: *

Description:

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

Source: src/core/Config.js#L223


inputMouse

inputMouse: boolean, object

Description:

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

Source: src/core/Config.js#L233


inputMouseEventTarget

inputMouseEventTarget: *

Description:

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

Source: src/core/Config.js#L238


inputMousePreventDefaultDown

inputMousePreventDefaultDown: boolean

Description:

Should mousedown DOM events have preventDefault called on them?

Source: src/core/Config.js#L243


inputMousePreventDefaultMove

inputMousePreventDefaultMove: boolean

Description:

Should mousemove DOM events have preventDefault called on them?

Source: src/core/Config.js#L253


inputMousePreventDefaultUp

inputMousePreventDefaultUp: boolean

Description:

Should mouseup DOM events have preventDefault called on them?

Source: src/core/Config.js#L248


inputMousePreventDefaultWheel

inputMousePreventDefaultWheel: boolean

Description:

Should wheel DOM events have preventDefault called on them?

Source: src/core/Config.js#L258


inputSmoothFactor

inputSmoothFactor: number

Description:

The smoothing factor to apply during Pointer movement. See Phaser.Input.Pointer#smoothFactor.

Source: src/core/Config.js#L283


inputTouch

inputTouch: boolean

Description:

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

Source: src/core/Config.js#L263


inputTouchCapture

inputTouchCapture: boolean

Description:

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

Source: src/core/Config.js#L273


inputTouchEventTarget

inputTouchEventTarget: *

Description:

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

Source: src/core/Config.js#L268


inputWindowEvents

inputWindowEvents: boolean

Description:

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

Source: src/core/Config.js#L288


installGlobalPlugins

installGlobalPlugins: any

Description:

An array of global plugins to be installed.

Source: src/core/Config.js#L597


installScenePlugins

installScenePlugins: any

Description:

An array of Scene level plugins to be installed.

Source: src/core/Config.js#L602


loaderAsync

loaderAsync: boolean

Description:

Should the XHR request use async or not?

Source: src/core/Config.js#L526


loaderBaseURL

loaderBaseURL: string

Description:

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

Source: src/core/Config.js#L501


loaderCrossOrigin

loaderCrossOrigin: string, undefined

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}.

Source: src/core/Config.js#L516


loaderImageLoadType

loaderImageLoadType: string

Description:

Optional load type for image, XHR is default, or HTMLImageElement for a lightweight way.

Source: src/core/Config.js#L556


loaderLocalScheme

loaderLocalScheme: Array.<string>

Description:

An array of schemes that the Loader considers as being 'local' files. Defaults to: [ 'file://', 'capacitor://' ].

Source: src/core/Config.js#L564


loaderMaxParallelDownloads

loaderMaxParallelDownloads: number

Description:

The maximum number of files the Loader will attempt to download in parallel. Defaults to 32, or 6 on Android where parallel connections are more constrained.

Source: src/core/Config.js#L511


loaderMaxRetries

loaderMaxRetries: number

Description:

The number of times to retry a file load if it fails.

Source: src/core/Config.js#L546


loaderPassword

loaderPassword: string

Description:

Optional password for all XHR requests.

Source: src/core/Config.js#L536


loaderPath

loaderPath: string

Description:

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

Source: src/core/Config.js#L506


loaderResponseType

loaderResponseType: string

Description:

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

Source: src/core/Config.js#L521


loaderTimeout

loaderTimeout: number

Description:

Optional XHR timeout value, in ms.

Source: src/core/Config.js#L541


loaderUser

loaderUser: string

Description:

Optional username for all XHR requests.

Source: src/core/Config.js#L531


loaderWithCredentials

loaderWithCredentials: boolean

Description:

Optional XHR withCredentials value.

Source: src/core/Config.js#L551


maxHeight

maxHeight: number

Description:

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

Source: src/core/Config.js#L120


maxLights

maxLights: number

Description:

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

Source: src/core/Config.js#L458


maxTextures

maxTextures: number

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.

Source: src/core/Config.js#L453


maxWidth

maxWidth: number

Description:

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

Source: src/core/Config.js#L110


minHeight

minHeight: number

Description:

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

Source: src/core/Config.js#L115


minWidth

minWidth: number

Description:

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

Source: src/core/Config.js#L105


mipmapFilter

mipmapFilter: string

Description:

Sets the mipmap magFilter to be used when creating WebGL textures. Don't set unless you wish to create mipmaps. Set to one of the following: 'NEAREST', 'LINEAR', 'NEAREST_MIPMAP_NEAREST', 'LINEAR_MIPMAP_NEAREST', 'NEAREST_MIPMAP_LINEAR' or 'LINEAR_MIPMAP_LINEAR'.

Source: src/core/Config.js#L364


missingImage

missingImage: string

Description:

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

Source: src/core/Config.js#L646


parent

parent: *

Description:

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

Source: src/core/Config.js#L70


pathDetailThreshold

pathDetailThreshold: number

Description:

Threshold for combining points into a single path in the WebGL renderer for Graphics objects. This can be overridden at the Graphics object level.

Source: src/core/Config.js#L384


physics

physics: Phaser.Types.Core.PhysicsConfig

Description:

The Physics Configuration object.

Source: src/core/Config.js#L491


pixelArt

pixelArt: boolean

Description:

Prevent pixel art from becoming blurred when scaled. It will remain crisp (tells the WebGL renderer to automatically create textures using a nearest-neighbor filter mode). When enabled, this also sets antialias and antialiasGL to false and roundPixels to true.

Source: src/core/Config.js#L389


postBoot

postBoot: Phaser.Types.Core.BootCallback

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.

Source: src/core/Config.js#L486


powerPreference

powerPreference: string

Description:

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

Source: src/core/Config.js#L443


preBoot

preBoot: Phaser.Types.Core.BootCallback

Description:

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

Source: src/core/Config.js#L481


premultipliedAlpha

premultipliedAlpha: boolean

Description:

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

Source: src/core/Config.js#L428


preserveDrawingBuffer

preserveDrawingBuffer: boolean

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.

Source: src/core/Config.js#L423


renderNodes

renderNodes: Object.<Phaser.Types.Core.RenderNodesConfig>

Description:

A map of custom Render Nodes to be added to the WebGL Renderer. The values will be added to the RenderNodeManager, using the keys as the names.

Source: src/core/Config.js#L463


renderType

renderType: number

Description:

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

Source: src/core/Config.js#L135


resizeInterval

resizeInterval: number

Description:

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

Source: src/core/Config.js#L95


roundPixels

roundPixels: boolean

Description:

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

Source: src/core/Config.js#L374


scaleMode

scaleMode: Phaser.Scale.ScaleModeType

Description:

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

Source: src/core/Config.js#L75


sceneConfig

sceneConfig: object

Description:

The default Scene configuration object.

Source: src/core/Config.js#L160


seed

seed: Array.<string>

Description:

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

Source: src/core/Config.js#L165


selfShadow

selfShadow: boolean

Description:

On textured objects with lighting, this enables self-shadowing based on the diffuse map.

Source: src/core/Config.js#L379


skipUnreadyShaders

skipUnreadyShaders: boolean

Description:

Avert stuttering during shader compilation, by enabling parallel shader compilation, where supported. Objects which request a shader that is not yet ready will not be drawn. This prevents stutter, but may cause "pop-in" of objects unless you use a pre-touch strategy.

Source: src/core/Config.js#L433


smoothPixelArt

smoothPixelArt: boolean

Description:

WebGL only. Sets antialias to true and pixelArt to false. Texture-based Game Objects use special shader setting that preserve blocky pixels, but smooth the edges between the pixels. This is only visible when objects are scaled up; otherwise, antialias is simpler.

Source: src/core/Config.js#L401


snapHeight

snapHeight: number

Description:

The vertical amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping.

Source: src/core/Config.js#L130


snapWidth

snapWidth: number

Description:

The horizontal amount to snap the canvas by when the Scale Manager is resizing. A value of zero means no snapping.

Source: src/core/Config.js#L125


stableSort

stableSort: number, boolean

Description:

false or 0 = Use the built-in StableSort (needed for older browsers), true or 1 = Rely on ES2019 Array.sort being stable (modern browsers only), or -1 = Try and determine this automatically based on browser inspection (not guaranteed to work, errs on side of caution).

Source: src/core/Config.js#L192


transparent

transparent: boolean

Description:

Whether the game canvas will have a transparent background.

Source: src/core/Config.js#L413


whiteImage

whiteImage: string

Description:

A base64 encoded PNG used as the default solid white texture. This small 4x4 white image is used internally by Phaser for colored Game Objects and tinting.

Source: src/core/Config.js#L651


width

width: number, string

Description:

The width of the underlying canvas, in pixels.

Source: src/core/Config.js#L55


zoom

zoom: Phaser.Scale.ZoomType, number

Description:

The zoom factor, as used by the Scale Manager.

Source: src/core/Config.js#L65