Skip to main content
Version: Phaser v4.0.0-rc.6

Types.Core

AudioConfig

<static> AudioConfig

Config object containing various sound settings.

nametypeoptionaldefaultdescription
disableWebAudiobooleanYesfalseUse HTML5 Audio instead of Web Audio.
contextAudioContextYesAn existing Web Audio context.
noAudiobooleanYesfalseDisable all audio output.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/AudioConfig.js#L1
Since: 3.0.0


BannerConfig

<static> BannerConfig

nametypeoptionaldefaultdescription
hidePhaserbooleanYesfalseOmit Phaser's name and version from the banner.
textstringYes"'#ffffff'"The color of the banner text.
backgroundArray.<string>YesThe background colors of the banner.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/BannerConfig.js#L1
Since: 3.0.0


BootCallback

<static> BootCallback

Type: function

Member of: Phaser.Types.Core

Source: src/core/typedefs/BootCallback.js#L1
Since: 3.0.0


CallbacksConfig

<static> CallbacksConfig

nametypeoptionaldefaultdescription
preBootPhaser.Types.Core.BootCallbackYes"Phaser.Types.Core.NOOP"A function to run at the start of the boot sequence.
postBootPhaser.Types.Core.BootCallbackYes"Phaser.Types.Core.NOOP"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: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/CallbacksConfig.js#L1
Since: 3.0.0


DOMContainerConfig

<static> DOMContainerConfig

nametypeoptionaldefaultdescription
createContainerbooleanYesfalseShould 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.
behindCanvasbooleanYesfalseShould 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?
pointerEventsstringYes"'none'"The default pointerEvents attribute set on the DOM Container.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/DOMContainerConfig.js#L1
Since: 3.12.0


FPSConfig

<static> FPSConfig

nametypeoptionaldefaultdescription
minnumberYes5The minimum acceptable rendering rate, in frames per second.
targetnumberYes60The optimum rendering rate, in frames per second. This does not enforce the fps rate, it merely tells Phaser what rate is considered optimal for this game.
limitnumberYes0Enforces an fps rate limit that the game step will run at, regardless of browser frequency. 0 means 'no limit'. Never set this higher than RAF can handle.
forceSetTimeOutbooleanYesfalseUse setTimeout instead of requestAnimationFrame to run the game loop.
deltaHistorynumberYes10Calculate the average frame delta from this many consecutive frame intervals.
panicMaxnumberYes120The amount of frames the time step counts before we trust the delta values again.
smoothStepbooleanYestrueApply delta smoothing during the game update to help avoid spikes?

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/FPSConfig.js#L1
Since: 3.0.0


GameConfig

<static> GameConfig

nametypeoptionaldefaultdescription
widthnumber | stringYes1024The width of the game, in game pixels.
heightnumber | stringYes768The height of the game, in game pixels.
zoomnumberYes1Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc.
typenumberYes"CONST.AUTO"Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS.
stableSortnumber | booleanYes-1true or 1 = Use the built-in StableSort (needed for older browsers), false or 0 = 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).
parentHTMLElement | stringnullYes
canvasHTMLCanvasElementYesnullProvide your own Canvas element for Phaser to use instead of creating one.
canvasStylestringYesnullCSS styles to apply to the game canvas instead of Phasers default styles.
customEnvironmentbooleanYesfalseIs 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.
contextCanvasRenderingContext2DYesProvide your own Canvas Context for Phaser to use, instead of creating one.
scenePhaser.Types.Scenes.SceneType | Array.<Phaser.Types.Scenes.SceneType>YesnullA scene or scenes to add to the game. If several are given, the first is started; the remainder are started only if they have { active: true }. See the sceneConfig argument in Phaser.Scenes.SceneManager#add.
seedArray.<string>YesSeed for the random number generator.
titlestringYes"''"The title of the game. Shown in the browser console.
urlstringYes"'https://phaser.io'"The URL of the game. Shown in the browser console.
versionstringYes"''"The version of the game. Shown in the browser console.
autoFocusbooleanYestrueAutomatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame.
inputboolean | Phaser.Types.Core.InputConfigYesInput configuration, or false to disable all game input.
disableContextMenubooleanYesfalseDisable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click).
bannerboolean | Phaser.Types.Core.BannerConfigYesfalseConfiguration for the banner printed in the browser console when the game starts.
domPhaser.Types.Core.DOMContainerConfigYesThe DOM Container configuration object.
fpsPhaser.Types.Core.FPSConfigYesGame loop configuration.
renderPhaser.Types.Core.RenderConfigYesGame renderer configuration.
callbacksPhaser.Types.Core.CallbacksConfigYesOptional callbacks to run before or after game boot.
loaderPhaser.Types.Core.LoaderConfigYesLoader configuration.
imagesPhaser.Types.Core.ImagesConfigYesImages configuration.
physicsPhaser.Types.Core.PhysicsConfigYesPhysics configuration.
pluginsPhaser.Types.Core.PluginObject | Array.<Phaser.Types.Core.PluginObjectItem>YesPlugins to install.
scalePhaser.Types.Core.ScaleConfigYesThe Scale Manager configuration.
audioPhaser.Types.Core.AudioConfigYesThe Audio Configuration object.
backgroundColorstring | numberYes"0x000000"The background color of the game canvas. The default is black.
antialiasbooleanYestrueWhen 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.
antialiasGLbooleanYestrueSets 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.
desynchronizedbooleanYesfalseWhen 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.
pixelArtbooleanYesfalseSets antialias to false and roundPixels to true. This is the best setting for pixel-art games.
smoothPixelArtbooleanYesfalseWebGL 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.
roundPixelsbooleanYesfalseDraw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property.
selfShadowbooleanYesfalseOn textured objects with lighting, this enables self-shadowing based on the diffuse map.
pathDetailThresholdnumberYes1Threshold for combining points into a single path in the WebGL renderer for Graphics objects. This can be overridden at the Graphics object level.
transparentbooleanYesfalseWhether the game canvas will be transparent. Boolean that indicates if the canvas contains an alpha channel. If set to false, the browser now knows that the backdrop is always opaque, which can speed up drawing of transparent content and images.
clearBeforeRenderbooleanYestrueWhether the game canvas will be cleared between each rendering frame.
preserveDrawingBufferbooleanYesfalseIf the value is true the WebGL buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
premultipliedAlphabooleanYestrueIn WebGL mode, the drawing buffer contains colors with pre-multiplied alpha.
skipUnreadyShadersbooleanYesfalseAvert 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.
failIfMajorPerformanceCaveatbooleanYesfalseLet the browser abort creating a WebGL context if it judges performance would be unacceptable.
powerPreferencestringYes"'default'""high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use.
batchSizenumberYes16384The default WebGL batch size. Represents the number of quads that can be added to a single batch.
maxLightsnumberYes10The maximum number of lights allowed to be visible within range of a single Camera in the LightManager.
maxTexturesnumberYes-1When 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.
mipmapFilterstringYes"'LINEAR'"The mipmap magFilter to be used when creating WebGL textures.
autoMobileTexturesbooleanYestrueIf iOS or Android detected, automatically restrict WebGL to use 1 texture per batch. This can help performance on some devices.
expandParentbooleanYestrueIs the Scale Manager allowed to adjust the CSS height property of the parent and/or document body to be 100%?
modePhaser.Scale.ScaleModeTypeYes"Phaser.Scale.ScaleModes.NONE"The scale mode.
minWidthHeightYesThe minimum width and height the canvas can be scaled down to.
maxWidthHeightYesThe maximum width the canvas can be scaled up to.
autoRoundbooleanYesfalseAutomatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices.
autoCenterPhaser.Scale.CenterTypeYes"Phaser.Scale.Center.NO_CENTER"Automatically center the canvas within the parent?
resizeIntervalnumberYes500How many ms should elapse before checking if the browser size has changed?
fullscreenTargetHTMLElement | stringYesThe 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: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/GameConfig.js#L1
Since: 3.0.0


GamepadInputConfig

<static> GamepadInputConfig

nametypeoptionaldefaultdescription
target*Yes"window"Where the Gamepad Manager listens for gamepad input events.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/GamepadInputConfig.js#L1
Since: 3.0.0


ImagesConfig

<static> ImagesConfig

nametypeoptionaldescription
defaultstring | undefinednullYes
missingstring | undefinednullYes
whitestring | undefinednullYes

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/ImagesConfig.js#L1
Since: 3.0.0


InputConfig

<static> InputConfig

nametypeoptionaldefaultdescription
keyboardboolean | Phaser.Types.Core.KeyboardInputConfigYestrueKeyboard input configuration. true uses the default configuration and false disables keyboard input.
mouseboolean | Phaser.Types.Core.MouseInputConfigYestrueMouse input configuration. true uses the default configuration and false disables mouse input.
touchboolean | Phaser.Types.Core.TouchInputConfigYestrueTouch input configuration. true uses the default configuration and false disables touch input.
gamepadboolean | Phaser.Types.Core.GamepadInputConfigYesfalseGamepad input configuration. true enables gamepad input.
activePointersnumberYes1The maximum number of touch pointers. See {@link Phaser.Input.InputManager#pointers}.
smoothFactornumberYes0The smoothing factor to apply during Pointer movement. See {@link Phaser.Input.Pointer#smoothFactor}.
windowEventsbooleanYestrueShould Phaser listen for input events on the Window? If you disable this, events like 'POINTER_UP_OUTSIDE' will no longer fire.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/InputConfig.js#L1
Since: 3.0.0


KeyboardInputConfig

<static> KeyboardInputConfig

nametypeoptionaldefaultdescription
target*Yes"window"Where the Keyboard Manager listens for keyboard input events.
captureArray.<number>YespreventDefault will be called on every non-modified key which has a key code in this array. By default it is empty.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/KeyboardInputConfig.js#L1
Since: 3.0.0


LoaderConfig

<static> LoaderConfig

nametypeoptionaldefaultdescription
baseURLstringYesA URL used to resolve paths given to the loader. Example: 'http://labs.phaser.io/assets/'.
pathstringYesA URL path used to resolve relative paths given to the loader. Example: 'images/sprites/'.
maxParallelDownloadsnumberYes32The maximum number of resources the loader will start loading at once.
crossOriginstring | undefinedYes'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}.
responseTypestringYesThe response type of the XHR request, e.g. blob, text, etc.
asyncbooleanYestrueShould the XHR request use async or not?
userstringYesOptional username for all XHR requests.
passwordstringYesOptional password for all XHR requests.
timeoutnumberYes0Optional XHR timeout value, in ms.
localSchemeArray.<string>YesAn optional array of schemes that the Loader considers as being 'local' files. Defaults to: [ 'file://', 'capacitor://' ] if not specified.
withCredentialsbooleanYesfalseOptional XHR withCredentials value.
imageLoadTypestringYes"'XHR'"Optional load type for image, XHR is default, or HTMLImageElement for a lightweight way.
maxRetriesnumberYes2The number of times to retry the file load if it fails.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/LoaderConfig.js#L1
Since: 3.0.0


MouseInputConfig

<static> MouseInputConfig

nametypeoptionaldefaultdescription
target*YesnullWhere the Mouse Manager listens for mouse input events. The default is the game canvas.
preventDefaultDownbooleanYestrueIf true the DOM mousedown event will have preventDefault set.
preventDefaultUpbooleanYestrueIf true the DOM mouseup event will have preventDefault set.
preventDefaultMovebooleanYestrueIf true the DOM mousemove event will have preventDefault set.
preventDefaultWheelbooleanYestrueIf true the DOM wheel event will have preventDefault set.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/MouseInputConfig.js#L1
Since: 3.0.0


NOOP

<static> NOOP

This callback type is completely empty, a no-operation.

Type: function

Member of: Phaser.Types.Core

Source: src/core/typedefs/NOOP.js#L1
Since: 3.0.0


PhysicsConfig

<static> PhysicsConfig

nametypeoptionaldescription
defaultstringYesThe default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'.
arcadePhaser.Types.Physics.Arcade.ArcadeWorldConfigYesArcade Physics configuration.
matterPhaser.Types.Physics.Matter.MatterWorldConfigYesMatter Physics configuration.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/PhysicsConfig.js#L1
Since: 3.0.0


PluginObject

<static> PluginObject

nametypeoptionaldescription
globalArray.<Phaser.Types.Core.PluginObjectItem>YesGlobal plugins to install.
sceneArray.<Phaser.Types.Core.PluginObjectItem>YesScene plugins to install.
defaultArray.<string>YesThe default set of scene plugins (names).
defaultMergeArray.<string>YesPlugins to add to the default set of scene plugins.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/PluginObject.js#L1
Since: 3.8.0


PluginObjectItem

<static> PluginObjectItem

nametypeoptionaldescription
keystringYesA key to identify the plugin in the Plugin Manager.
plugin*YesThe plugin itself. Usually a class/constructor.
startbooleanYesWhether the plugin should be started automatically.
systemKeystringYesFor a scene plugin, add the plugin to the scene's systems object under this key (this.sys.KEY, from the scene).
sceneKeystringYesFor a scene plugin, add the plugin to the scene object under this key (this.KEY, from the scene).
mappingstringYesIf this plugin is to be injected into the Scene Systems, this is the property key map used.
data*YesArbitrary data passed to the plugin's init() method.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/PluginObjectItem.js#L1
Since: 3.8.0


RenderConfig

<static> RenderConfig

nametypeoptionaldefaultdescription
antialiasbooleanYestrueWhen 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.
antialiasGLbooleanYestrueSets 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.
desynchronizedbooleanYesfalseWhen 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.
pixelArtbooleanYesfalseSets antialias to false and roundPixels to true. This is the best setting for pixel-art games.
smoothPixelArtbooleanYesfalseWebGL 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.
roundPixelsbooleanYesfalseDraw texture-based Game Objects at only whole-integer positions. Game Objects without textures, like Graphics, ignore this property.
selfShadowbooleanYesfalseOn textured objects with lighting, this enables self-shadowing based on the diffuse map.
pathDetailThresholdnumberYes1Threshold for combining points into a single path in the WebGL renderer for Graphics objects. This can be overridden at the Graphics object level.
transparentbooleanYesfalseWhether the game canvas will be transparent. Boolean that indicates if the canvas contains an alpha channel. If set to false, the browser now knows that the backdrop is always opaque, which can speed up drawing of transparent content and images.
clearBeforeRenderbooleanYestrueWhether the game canvas will be cleared between each rendering frame.
preserveDrawingBufferbooleanYesfalseIf the value is true the WebGL buffers will not be cleared and will preserve their values until cleared or overwritten by the author.
premultipliedAlphabooleanYestrueIn WebGL mode, the drawing buffer contains colors with pre-multiplied alpha.
skipUnreadyShadersbooleanYesfalseAvert 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.
failIfMajorPerformanceCaveatbooleanYesfalseLet the browser abort creating a WebGL context if it judges performance would be unacceptable.
powerPreferencestringYes"'default'""high-performance", "low-power" or "default". A hint to the browser on how much device power the game might use.
batchSizenumberYes16384The default WebGL batch size. Represents the number of quads that can be added to a single batch.
maxLightsnumberYes10The maximum number of lights allowed to be visible within range of a single Camera in the LightManager.
maxTexturesnumberYes-1When 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.
mipmapFilterstringYes"''"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'.
autoMobileTexturesbooleanYestrueIf iOS or Android detected, automatically restrict WebGL to use 1 texture per batch. This can help performance on some devices.
renderNodesObject.<Phaser.Types.Core.RenderNodesConfig>YesA 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.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/RenderConfig.js#L1
Since: 3.0.0


RenderNodesConfig

<static> RenderNodesConfig

nametypeoptionaldescription
keystringYesA key to be used as the name of the RenderNode.
function*YesThe Render Node function itself.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/RenderNodesConfig.js#L1
Since: 4.0.0


ScaleConfig

<static> ScaleConfig

nametypeoptionaldefaultdescription
widthnumber | stringYes1024The base width of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size.
heightnumber | stringYes768The base height of your game. Can be an integer or a string: '100%'. If a string it will only work if you have set a parent element that has a size.
zoomPhaser.Scale.ZoomType | numberYes1The zoom value of the game canvas.
parentHTMLElement | stringYesThe DOM element that will contain the game canvas, or its id. If undefined, or if the named element doesn't exist, the game canvas is inserted directly into the document body. If null no parent will be used and you are responsible for adding the canvas to your environment.
expandParentbooleanYestrueIs the Scale Manager allowed to adjust the CSS height property of the parent and/or document body to be 100%?
modePhaser.Scale.ScaleModeTypeYes"Phaser.Scale.ScaleModes.NONE"The scale mode.
minWidthHeightYesThe minimum width and height the canvas can be scaled down to.
maxWidthHeightYesThe maximum width the canvas can be scaled up to.
snapWidthHeightYesSet the snapping values used by the Scale Manager when resizing the canvas. See ScaleManager.setSnap for details.
autoRoundbooleanYesfalseAutomatically round the display and style sizes of the canvas. This can help with performance in lower-powered devices.
autoCenterPhaser.Scale.CenterTypeYes"Phaser.Scale.Center.NO_CENTER"Automatically center the canvas within the parent?
resizeIntervalnumberYes500How many ms should elapse before checking if the browser size has changed?
fullscreenTargetHTMLElement | stringYesThe 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: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/ScaleConfig.js#L1
Since: 3.16.0


TimeStepCallback

<static> TimeStepCallback

Type: function

Member of: Phaser.Types.Core

Source: src/core/typedefs/TimeStepCallback.js#L1
Since: 3.0.0


TouchInputConfig

<static> TouchInputConfig

nametypeoptionaldefaultdescription
target*YesnullWhere the Touch Manager listens for touch input events. The default is the game canvas.
capturebooleanYestrueWhether touch input events have preventDefault() called on them.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/TouchInputConfig.js#L1
Since: 3.0.0


WidthHeight

<static> WidthHeight

nametypeoptionaldefaultdescription
widthnumberYes0The width.
heightnumberYes0The height.

Type: object

Member of: Phaser.Types.Core

Source: src/core/typedefs/WidthHeight.js#L1
Since: 3.16.0