Phaser API Documentation

  Version: 
GameConfig
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.

stableSort number | boolean <optional> -1

true 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).

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 Phaser.Types.Scenes.SceneType | Array.<Phaser.Types.Scenes.SceneType> <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.

autoMobilePipeline boolean <optional> true

Automatically enable the Mobile Pipeline if iOS or Android detected?

defaultPipeline string <optional> 'MultiPipeline'

The WebGL Pipeline that Game Objects will use by default. Set to 'MultiPipeline' as standard.

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