Phaser API Documentation


Member of: Phaser.Types.Core

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> ''

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

Since: 3.0.0