Namespace: Core

Phaser.Types. Core

Type Definitions


AudioConfig

Config object containing various sound settings.

Type:
  • object
Properties:
Name Type Argument Default Description
disableWebAudio boolean <optional>
false

Use HTML5 Audio instead of Web Audio.

context AudioContext <optional>

An existing Web Audio context.

noAudio boolean <optional>
false

Disable all audio output.

Since: 3.0.0
Source: src/core/typedefs/AudioConfig.js (Line 1)
See:

BannerConfig

Type:
  • object
Properties:
Name Type Argument Default Description
hidePhaser boolean <optional>
false

Omit Phaser's name and version from the banner.

text string <optional>
'#ffffff'

The color of the banner text.

background Array.<string> <optional>

The background colors of the banner.

Since: 3.0.0
Source: src/core/typedefs/BannerConfig.js (Line 1)

BootCallback(game)

Parameters:
Name Type Description
game Phaser.Game

The game.

Since: 3.0.0
Source: src/core/typedefs/BootCallback.js (Line 1)

CallbacksConfig

Type:
  • object
Properties:
Name Type Argument Default Description
preBoot Phaser.Types.Core.BootCallback <optional>
Phaser.Types.Core.NOOP

A function to run at the start of the boot sequence.

postBoot Phaser.Types.Core.BootCallback <optional>
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.

Since: 3.0.0
Source: src/core/typedefs/CallbacksConfig.js (Line 1)

DOMContainerConfig

Type:
  • object
Properties:
Name Type Argument Default Description
createContainer boolean <optional>
false

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.

behindCanvas boolean <optional>
false

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?

Since: 3.12.0
Source: src/core/typedefs/DOMContainerConfig.js (Line 1)

FPSConfig

Type:
  • object
Properties:
Name Type Argument Default Description
min integer <optional>
5

The minimum acceptable rendering rate, in frames per second.

target integer <optional>
60

The optimum rendering rate, in frames per second.

forceSetTimeOut boolean <optional>
false

Use setTimeout instead of requestAnimationFrame to run the game loop.

deltaHistory integer <optional>
10

Calculate the average frame delta from this many consecutive frame intervals.

panicMax integer <optional>
120

The amount of frames the time step counts before we trust the delta values again.

Since: 3.0.0
Source: src/core/typedefs/FPSConfig.js (Line 1)

GameConfig

Type:
  • object
Properties:
Name Type Argument Default Description
width integer | string <optional>
1024

The width of the game, in game pixels.

height integer | string <optional>
768

The height of the game, in game pixels.

zoom number <optional>
1

Simple scale applied to the game canvas. 2 is double size, 0.5 is half size, etc.

resolution number <optional>
1

The size of each game pixel, in canvas pixels. Values larger than 1 are "high" resolution.

type number <optional>
CONST.AUTO

Which renderer to use. Phaser.AUTO, Phaser.CANVAS, Phaser.HEADLESS, or Phaser.WEBGL. AUTO picks WEBGL if available, otherwise CANVAS.

parent HTMLElement | string <optional>
null

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

canvas HTMLCanvasElement <optional>
null

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

canvasStyle string <optional>
null

CSS styles to apply to the game canvas instead of Phasers default styles.

customEnvironment boolean <optional>
false

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.

context CanvasRenderingContext2D <optional>

Provide your own Canvas Context for Phaser to use, instead of creating one.

scene Phaser.Scene | Array.<Phaser.Scene> | Phaser.Types.Scenes.SettingsConfig | Array.<Phaser.Types.Scenes.SettingsConfig> | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Array.<Phaser.Types.Scenes.CreateSceneFromObjectConfig> | function | Array.<function()> <optional>
null

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

seed Array.<string> <optional>

Seed for the random number generator.

title string <optional>
''

The title of the game. Shown in the browser console.

url string <optional>
'http://phaser.io'

The URL of the game. Shown in the browser console.

version string <optional>
''

The version of the game. Shown in the browser console.

autoFocus boolean <optional>
true

Automatically call window.focus() when the game boots. Usually necessary to capture input events if the game is in a separate frame.

input boolean | Phaser.Types.Core.InputConfig <optional>

Input configuration, or false to disable all game input.

disableContextMenu boolean <optional>
false

Disable the browser's default 'contextmenu' event (usually triggered by a right-button mouse click).

transparent boolean <optional>
false

Whether the game canvas will have a transparent background.

banner boolean | Phaser.Types.Core.BannerConfig <optional>
false

Configuration for the banner printed in the browser console when the game starts.

dom Phaser.Types.Core.DOMContainerConfig <optional>

The DOM Container configuration object.

fps Phaser.Types.Core.FPSConfig <optional>

Game loop configuration.

render Phaser.Types.Core.RenderConfig <optional>

Game renderer configuration.

backgroundColor string | number <optional>
0x000000

The background color of the game canvas. The default is black.

callbacks Phaser.Types.Core.CallbacksConfig <optional>

Optional callbacks to run before or after game boot.

loader Phaser.Types.Core.LoaderConfig <optional>

Loader configuration.

images Phaser.Types.Core.ImagesConfig <optional>

Images configuration.

physics Phaser.Types.Core.PhysicsConfig <optional>

Physics configuration.

plugins Phaser.Types.Core.PluginObject | Array.<Phaser.Types.Core.PluginObjectItem> <optional>

Plugins to install.

scale Phaser.Types.Core.ScaleConfig <optional>

The Scale Manager configuration.

audio Phaser.Types.Core.AudioConfig <optional>

The Audio Configuration object.

Since: 3.0.0
Source: src/core/typedefs/GameConfig.js (Line 1)

GamepadInputConfig

Type:
  • object
Properties:
Name Type Argument Default Description
target * <optional>
window

Where the Gamepad Manager listens for gamepad input events.

Since: 3.0.0
Source: src/core/typedefs/GamepadInputConfig.js (Line 1)

ImagesConfig

Type:
  • object
Properties:
Name Type Argument Description
default string <optional>

URL to use for the 'default' texture.

missing string <optional>

URL to use for the 'missing' texture.

Since: 3.0.0
Source: src/core/typedefs/ImagesConfig.js (Line 1)

InputConfig

Type:
  • object
Properties:
Name Type Argument Default Description
keyboard boolean | Phaser.Types.Core.KeyboardInputConfig <optional>
true

Keyboard input configuration. true uses the default configuration and false disables keyboard input.

mouse boolean | Phaser.Types.Core.MouseInputConfig <optional>
true

Mouse input configuration. true uses the default configuration and false disables mouse input.

touch boolean | Phaser.Types.Core.TouchInputConfig <optional>
true

Touch input configuration. true uses the default configuration and false disables touch input.

gamepad boolean | Phaser.Types.Core.GamepadInputConfig <optional>
false

Gamepad input configuration. true enables gamepad input.

activePointers integer <optional>
1

The maximum number of touch pointers. See Phaser.Input.InputManager#pointers.

smoothFactor number <optional>
0

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

windowEvents boolean <optional>
true

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

Since: 3.0.0
Source: src/core/typedefs/InputConfig.js (Line 1)

KeyboardInputConfig

Type:
  • object
Properties:
Name Type Argument Default Description
target * <optional>
window

Where the Keyboard Manager listens for keyboard input events.

capture Array.<integer> <optional>
<nullable>

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

Since: 3.0.0
Source: src/core/typedefs/KeyboardInputConfig.js (Line 1)

LoaderConfig

Type:
  • object
Properties:
Name Type Argument Default Description
baseURL string <optional>

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

path string <optional>

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

maxParallelDownloads integer <optional>
32

The maximum number of resources the loader will start loading at once.

crossOrigin string | undefined <optional>

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

responseType string <optional>

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

async boolean <optional>
true

Should the XHR request use async or not?

user string <optional>

Optional username for all XHR requests.

password string <optional>

Optional password for all XHR requests.

timeout integer <optional>
0

Optional XHR timeout value, in ms.

Since: 3.0.0
Source: src/core/typedefs/LoaderConfig.js (Line 1)

MouseInputConfig

Type:
  • object
Properties:
Name Type Argument Default Description
target * <optional>
null

Where the Mouse Manager listens for mouse input events. The default is the game canvas.

capture boolean <optional>
true

Whether mouse input events have preventDefault called on them.

Since: 3.0.0
Source: src/core/typedefs/MouseInputConfig.js (Line 1)

NOOP()

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

Since: 3.0.0
Source: src/core/typedefs/NOOP.js (Line 1)

PhysicsConfig

Type:
  • object
Properties:
Name Type Argument Description
default string <optional>

The default physics system. It will be started for each scene. Phaser provides 'arcade', 'impact', and 'matter'.

arcade Phaser.Types.Physics.Arcade.ArcadeWorldConfig <optional>

Arcade Physics configuration.

impact Phaser.Types.Physics.Impact.WorldConfig <optional>

Impact Physics configuration.

matter Phaser.Types.Physics.Matter.MatterWorldConfig <optional>

Matter Physics configuration.

Since: 3.0.0
Source: src/core/typedefs/PhysicsConfig.js (Line 1)

PluginObject

Type:
  • object
Properties:
Name Type Argument Description
global Array.<Phaser.Types.Core.PluginObjectItem> <optional>
<nullable>

Global plugins to install.

scene Array.<Phaser.Types.Core.PluginObjectItem> <optional>
<nullable>

Scene plugins to install.

default Array.<string> <optional>

The default set of scene plugins (names).

defaultMerge Array.<string> <optional>

Plugins to add to the default set of scene plugins.

Since: 3.8.0
Source: src/core/typedefs/PluginObject.js (Line 1)

PluginObjectItem

Type:
  • object
Properties:
Name Type Argument Description
key string <optional>

A key to identify the plugin in the Plugin Manager.

plugin * <optional>

The plugin itself. Usually a class/constructor.

start boolean <optional>

Whether the plugin should be started automatically.

systemKey string <optional>

For a scene plugin, add the plugin to the scene's systems object under this key (this.sys.KEY, from the scene).

sceneKey string <optional>

For a scene plugin, add the plugin to the scene object under this key (this.KEY, from the scene).

mapping string <optional>

If this plugin is to be injected into the Scene Systems, this is the property key map used.

data * <optional>

Arbitrary data passed to the plugin's init() method.

Since: 3.8.0
Source: src/core/typedefs/PluginObjectItem.js (Line 1)
Examples
// Global plugin
{ key: 'BankPlugin', plugin: BankPluginV3, start: true, data: { gold: 5000 } }
// Scene plugin
{ key: 'WireFramePlugin', plugin: WireFramePlugin, systemKey: 'wireFramePlugin', sceneKey: 'wireframe' }

RenderConfig

Type:
  • object
Properties:
Name Type Argument Default Description
antialias boolean <optional>
true

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.

antialiasGL boolean <optional>
true

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.

desynchronized boolean <optional>
false

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.

pixelArt boolean <optional>
false

Sets antialias and roundPixels to true. This is the best setting for pixel-art games.

roundPixels boolean <optional>
false

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

transparent boolean <optional>
false

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

clearBeforeRender boolean <optional>
true

Whether the game canvas will be cleared between each rendering frame.

premultipliedAlpha boolean <optional>
true

In WebGL mode, the drawing buffer contains colors with pre-multiplied alpha.

failIfMajorPerformanceCaveat boolean <optional>
false

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

powerPreference string <optional>
'default'

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

batchSize integer <optional>
2000

The default WebGL batch size.

maxLights integer <optional>
10

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

mipmapFilter string <optional>
'LINEAR'

The mipmap magFilter to be used when creating WebGL textures.

Since: 3.0.0
Source: src/core/typedefs/RenderConfig.js (Line 1)

ScaleConfig

Type:
  • object
Properties:
Name Type Argument Default Description
width integer | string <optional>
1024

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

height integer | string <optional>
768

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

zoom Phaser.Scale.ZoomType | integer <optional>
1

The zoom value of the game canvas.

resolution number <optional>
1

The rendering resolution of the canvas. This is reserved for future use and is currently ignored.

parent HTMLElement | string <optional>
<nullable>

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

expandParent boolean <optional>
true

Is the Scale Manager allowed to adjust the CSS height property of the parent and/or document body to be 100%?

mode Phaser.Scale.ScaleModeType <optional>
Phaser.Scale.ScaleModes.NONE

The scale mode.

min WidthHeight <optional>

The minimum width and height the canvas can be scaled down to.

max WidthHeight <optional>

The maximum width the canvas can be scaled up to.

autoRound boolean <optional>
false

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

autoCenter Phaser.Scale.CenterType <optional>
Phaser.Scale.Center.NO_CENTER

Automatically center the canvas within the parent?

resizeInterval integer <optional>
500

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

fullscreenTarget HTMLElement | string <optional>
<nullable>

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.

Since: 3.16.0
Source: src/core/typedefs/ScaleConfig.js (Line 1)

TimeStepCallback(time, average, interpolation)

Parameters:
Name Type Description
time number

The current time. Either a High Resolution Timer value if it comes from Request Animation Frame, or Date.now if using SetTimeout.

average number

The Delta Average.

interpolation number

Interpolation - how far between what is expected and where we are?

Since: 3.0.0
Source: src/core/typedefs/TimeStepCallback.js (Line 1)

TouchInputConfig

Type:
  • object
Properties:
Name Type Argument Default Description
target * <optional>
null

Where the Touch Manager listens for touch input events. The default is the game canvas.

capture boolean <optional>
true

Whether touch input events have preventDefault() called on them.

Since: 3.0.0
Source: src/core/typedefs/TouchInputConfig.js (Line 1)

WidthHeight

Type:
  • object
Properties:
Name Type Argument Default Description
width integer <optional>
0

The width.

height integer <optional>
0

The height.

Since: 3.16.0
Source: src/core/typedefs/WidthHeight.js (Line 1)