Phaser API Documentation

  Version: 
Filter
Namespace: Core
Phaser.Types.Core
Source: src/core/typedefs/index.js (Line 7)

Type Definitions

AudioConfig
Focus
Focus

Description:

Config object containing various sound settings.

Properties:
name type arguments 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.

Type:
object
Since: 3.0.0
Focus
Focus
BannerConfig
Focus
Focus
Properties:
name type arguments 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.

Type:
object
Since: 3.0.0
Focus
Focus
BootCallback(game)
Focus
Focus

Parameters:

name type description
game Phaser.Game

The game.

Type:
function
Since: 3.0.0
Focus
Focus
CallbacksConfig
Focus
Focus
Properties:
name type arguments 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.

Type:
object
Since: 3.0.0
Focus
Focus
DOMContainerConfig
Focus
Focus
Properties:
name type arguments 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?

pointerEvents string <optional> 'none'

The default pointerEvents attribute set on the DOM Container.

Type:
object
Since: 3.12.0
Focus
Focus
FPSConfig
Focus
Focus
Properties:
name type arguments Default description
min number <optional> 5

The minimum acceptable rendering rate, in frames per second.

target number <optional> 60

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

forceSetTimeOut boolean <optional> false

Use setTimeout instead of requestAnimationFrame to run the game loop.

deltaHistory number <optional> 10

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

panicMax number <optional> 120

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

smoothStep boolean <optional> true

Apply delta smoothing during the game update to help avoid spikes?

Type:
object
Since: 3.0.0
Focus
Focus
GameConfig
Focus
Focus
Properties:
name type arguments Default description
width number | string <optional> 1024

The width of the game, in game pixels.

height number | 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.

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>

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 appended to the document body. If null no parent will be used and you are responsible for adding the canvas to the dom.

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 function | Array.<function()> | Phaser.Scene | Array.<Phaser.Scene> | Phaser.Types.Scenes.SettingsConfig | Array.<Phaser.Types.Scenes.SettingsConfig> | Phaser.Types.Scenes.CreateSceneFromObjectConfig | Array.<Phaser.Types.Scenes.CreateSceneFromObjectConfig> <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> 'https://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).

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.

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.

pipeline Phaser.Types.Core.PipelineConfig <optional>

A WebGL Pipeline configuration object. Can also be part of the RenderConfig.

backgroundColor string | number <optional> 0x000000

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

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 to false 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.

preserveDrawingBuffer boolean <optional> false

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

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 number <optional> 4096

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

maxLights number <optional> 10

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

maxTextures number <optional> -1

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.

mipmapFilter string <optional> 'LINEAR'

The mipmap magFilter to be used when creating WebGL textures.

Type:
object
Since: 3.0.0
Focus
Focus
GamepadInputConfig
Focus
Focus
Properties:
name type arguments Default description
target * <optional> window

Where the Gamepad Manager listens for gamepad input events.

Type:
object
Since: 3.0.0
Focus
Focus
ImagesConfig
Focus
Focus
Properties:
name type arguments description
default string <optional>

A base64 encoded image file to use as the 'default' texture.

missing string <optional>

A base64 encoded image file to use as the 'missing' texture.

white string <optional>

A base64 encoded image file to use as the 'white' texture.

Type:
object
Since: 3.0.0
Focus
Focus
InputConfig
Focus
Focus
Properties:
name type arguments 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 number <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.

Type:
object
Since: 3.0.0
Focus
Focus
KeyboardInputConfig
Focus
Focus
Properties:
name type arguments Default description
target * <optional> window

Where the Keyboard Manager listens for keyboard input events.

capture Array.<number> <optional>

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

Type:
object
Since: 3.0.0
Focus
Focus
LoaderConfig
Focus
Focus
Properties:
name type arguments 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 number <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 {@link 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 number <optional> 0

Optional XHR timeout value, in ms.

Type:
object
Since: 3.0.0
Focus
Focus
MouseInputConfig
Focus
Focus
Properties:
name type arguments Default description
target * <optional> null

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

preventDefaultDown boolean <optional> true

If true the DOM mousedown event will have preventDefault set.

preventDefaultUp boolean <optional> true

If true the DOM mouseup event will have preventDefault set.

preventDefaultMove boolean <optional> true

If true the DOM mousemove event will have preventDefault set.

preventDefaultWheel boolean <optional> true

If true the DOM wheel event will have preventDefault set.

Type:
object
Since: 3.0.0
Focus
Focus
NOOP()
Focus
Focus

Description:

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

Type:
function
Since: 3.0.0
Source: src/core/typedefs/NOOP.js (Line 1)
Focus
Focus
PhysicsConfig
Focus
Focus
Properties:
name type arguments 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.

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

Matter Physics configuration.

Type:
object
Since: 3.0.0
Focus
Focus
PipelineConfig
Focus
Focus
Properties:
name type description
name string

The name of the pipeline. Must be unique within the Pipeline Manager.

pipeline Phaser.Renderer.WebGL.WebGLPipeline

The pipeline class. This should be a constructable object, not an instance of a class.

Type:
object
Since: 3.50.0
Focus
Focus
PluginObject
Focus
Focus
Properties:
name type arguments description
global Array.<Phaser.Types.Core.PluginObjectItem> <optional>

Global plugins to install.

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

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.

Type:
object
Since: 3.8.0
Focus
Focus
PluginObjectItem
Focus
Focus
Properties:
name type arguments 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.

Type:
object
Since: 3.8.0
Focus
Focus
RenderConfig
Focus
Focus
Properties:
name type arguments 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 to false 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.

preserveDrawingBuffer boolean <optional> false

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

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 number <optional> 4096

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

maxLights number <optional> 10

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

maxTextures number <optional> -1

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.

mipmapFilter string <optional> 'LINEAR'

The mipmap magFilter to be used when creating WebGL textures.

pipeline Phaser.Types.Core.PipelineConfig <optional>

The WebGL Pipeline configuration object.

Type:
object
Since: 3.0.0
Focus
Focus
ScaleConfig
Focus
Focus
Properties:
name type arguments Default description
width number | 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 number | 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 number | Phaser.Scale.ZoomType <optional> 1

The zoom value of the game canvas.

parent HTMLElement | string <optional>

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 number <optional> 500

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

fullscreenTarget HTMLElement | string <optional>

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:
object
Since: 3.16.0
Focus
Focus
TimeStepCallback(time, average, interpolation)
Focus
Focus

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?

Type:
function
Since: 3.0.0
Focus
Focus
TouchInputConfig
Focus
Focus
Properties:
name type arguments 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.

Type:
object
Since: 3.0.0
Focus
Focus
WidthHeight
Focus
Focus
Properties:
name type arguments description
width number <optional>

The width.

height number <optional>

The height.

Type:
object
Since: 3.16.0
Focus
Focus