Game

Creates a new Phaser.Game instance

Props

NameTypeDefaultDescription
antialias
boolean

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

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.

audio
AudioConfig

The Audio Configuration object.

autoFocus
boolean

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

backgroundColor
string number

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

banner
boolean BannerConfig

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

batchSize
number

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

callbacks
CallbacksConfig

Optional callbacks to run before or after game boot.

canvas
HTMLCanvasElement

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

canvasStyle
string

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

clearBeforeRender
boolean

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

context
CanvasRenderingContext2D

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

customEnvironment
boolean

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.

desynchronized
boolean

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.

disableContextMenu
boolean

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

dom
DOMContainerConfig

The DOM Container configuration object.

failIfMajorPerformanceCaveat
boolean

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

fps
FPSConfig

Game loop configuration.

height
string number

The height of the game, in game pixels.

images
ImagesConfig

Images configuration.

input
boolean InputConfig

Input configuration, or false to disable all game input.

loader
LoaderConfig

Loader configuration.

maxLights
number

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

maxTextures
number

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

The mipmap magFilter to be used when creating WebGL textures.

parent
string HTMLElement

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.

physics
PhysicsConfig

Physics configuration.

pipeline
PipelineConfig

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

pixelArt
boolean

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

plugins
PluginObject PluginObjectItem[]

Plugins to install.

powerPreference
string

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

premultipliedAlpha
boolean

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

preserveDrawingBuffer
boolean

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

ref
Ref

 

render
RenderConfig

Game renderer configuration.

roundPixels
boolean

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

scale
ScaleConfig

The Scale Manager configuration.

scene
Function Scene Scene[] SettingsConfig SettingsConfig[] CreateSceneFromObjectConfig CreateSceneFromObjectConfig[] Function[]

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
string[]

Seed for the random number generator.

title
string

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

transparent
boolean

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.

type
number

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

url
string

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

version
string

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

width
string number

The width of the game, in game pixels.

zoom
number

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