Skip to main content
Version: Phaser v4.0.0

Phaser.Core

Scope: static

Source: src/core/index.js#L7

Static functions

Static functions

CreateRenderer

<static> CreateRenderer(game)

Description:

Called automatically by Phaser.Game and responsible for creating the renderer it will use.

Inspects the game configuration to determine the appropriate render type (WebGL, Canvas, or Headless), validates that the chosen renderer is supported by the current device, sets up the canvas element (either adopting one provided in the game config or creating a new one from the CanvasPool), applies any canvas CSS styles and pixel art interpolation settings, then instantiates and assigns the renderer to game.renderer.

Relies upon two webpack global flags, WEBGL_RENDERER and CANVAS_RENDERER, which are defined at build time and inlined into the bundle as compile-time constants. They are not available as runtime variables and determine which renderer classes are included in the build.

Parameters:

nametypeoptionaldescription
gamePhaser.GameNoThe Phaser.Game instance on which the renderer will be set.

Source: src/core/CreateRenderer.js#L12
Since: 3.0.0


DebugHeader

<static> DebugHeader(game)

Description:

Called automatically by Phaser.Game during initialization to output a styled banner to the browser console. The banner displays the Phaser version number, the active renderer (WebGL, Canvas, or Headless), the audio system in use (Web Audio, HTML5 Audio, or No Audio), and optionally the game title, version, and URL as configured. In browsers that support CSS console styling the banner is rendered with the colors defined in the Game Config; in IE it falls back to a plain text log. The banner is skipped entirely when config.hideBanner is true.

You can customize or disable the header via the Game Config object.

Parameters:

nametypeoptionaldescription
gamePhaser.GameNoThe Phaser.Game instance which will output this debug header.

Source: src/core/DebugHeader.js#L9
Since: 3.0.0


VisibilityHandler

<static> VisibilityHandler(game)

Description:

The Visibility Handler is responsible for listening for document-level visibility change events and window blur/focus events, then re-emitting them through the Game's Event Emitter so that the rest of the framework can respond appropriately — for example, pausing the game loop when the player switches tabs or minimizes the browser window, and resuming it when they return.

It listens for the standard visibilitychange event where supported, and falls back to vendor-prefixed equivalents (webkitvisibilitychange, mozvisibilitychange, msvisibilitychange) for older browsers. Window-level blur and focus events are also captured to handle cases where the tab remains visible but the window loses focus.

If the game configuration has autoFocus enabled, the handler will also call window.focus() during setup to ensure the game captures keyboard input immediately on load.

Parameters:

nametypeoptionaldescription
gamePhaser.GameNoThe Game instance this Visibility Handler is working on.

Fires: Phaser.Core.Events#event:BLUR, Phaser.Core.Events#event:FOCUS, Phaser.Core.Events#event:HIDDEN, Phaser.Core.Events#event:VISIBLE

Source: src/core/VisibilityHandler.js#L9
Since: 3.0.0


Static functions