Phaser.Game

new Game(config)

Instead of specifying arguments you can also pass a single object instead:

var config = {
    width: 800,
    height: 600,
    renderer: Phaser.AUTO,
    antialias: true,
    multiTexture: true,
    state: {
        preload: preload,
        create: create,
        update: update
    }
}

var game = new Phaser.Game(config);

Parameters:

Name

Type

Argument

Description

config

object

<optional>

A single configuration object

Properties

Name

Type

Argument

Default

Description

antialias

number | string

<optional>

true

height

number | string

<optional>

600

enableDebug

boolean

<optional>

true

Enable Phaser.Utils.Debug. You can gain a little performance by disabling this in production.

fullScreenScaleMode

number

<optional>

The scaling method used by the ScaleManager when in fullscreen.

fullScreenTarget

DOMElement

<optional>

The DOM element on which the Fullscreen API enter request will be invoked.

multiTexture

boolean

<optional>

false

Enable support for multiple bound Textures in WebGL. Same as renderer: Phaser.WEBGL_MULTI.

parent

string | HTMLElement

<optional>

''

physicsConfig

object

<optional>

null

preserveDrawingBuffer

boolean

<optional>

false

Whether or not the contents of the stencil buffer is retained after rendering.

renderer

number

<optional>

Phaser.AUTO

resolution

number

<optional>

1

The resolution of your game, as a ratio of canvas pixels to game pixels.

scaleMode

number

<optional>

The scaling method used by the ScaleManager when not in fullscreen.

seed

number

<optional>

Seed for Phaser.RandomDataGenerator.

state

object

<optional>

null

transparent

boolean

<optional>

false

width

number | string

<optional>

800

Source - core/Game.js, line 95

Members

add:Phaser.GameObjectFactory

Reference to the Phaser.GameObjectFactory.

Source - core/Game.js, line 241

<readonly>antialias:boolean

Anti-alias graphics (as set when the Game is created). By default scaled and rotated images are smoothed in Canvas and WebGL; set antialias to false to disable this globally. After the game boots, use game.stage.smoothed instead.

Default Value: - true

Source - core/Game.js, line 174

cache:Phaser.Cache

Reference to the assets cache.

Source - core/Game.js, line 251

camera:Phaser.Camera

A handy reference to world.camera.

Source - core/Game.js, line 326

canvas:HTMLCanvasElement

A handy reference to renderer.view, the canvas that the game is being rendered in to.

Source - core/Game.js, line 331

clearBeforeRender:boolean

Clear the Canvas each frame before rendering the display list. You can set this to false to gain some performance if your game always contains a background that completely fills the display.

Default Value: - true

Source - core/Game.js, line 201

config:object

The Phaser.Game configuration object.

Source - core/Game.js, line 106

context:CanvasRenderingContext2D

A handy reference to renderer.context (only set for CANVAS games, notWebGL)

Source - core/Game.js, line 336

create:Phaser.Create

The Asset Generator.

Source - core/Game.js, line 351

<internal>currentUpdateID:integer

The ID of the current/last logic update applied this render frame, starting from 0. The first update is currentUpdateID === 0 and the last update is currentUpdateID === updatesThisFrame.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 421

debug:Phaser.Utils.Debug

A set of useful debug utilities.

Source - core/Game.js, line 341

device:Phaser.Device

Contains device information and capabilities.

Source - core/Game.js, line 321

forceSingleUpdate:boolean

Should the game loop force a logic update, regardless of the delta timer? You can toggle it on the fly.

Source - core/Game.js, line 465

fpsProblemNotifier:Phaser.Signal

If the game is struggling to maintain the desired FPS, this signal will be dispatched. The desired/chosen FPS should probably be closer to the Phaser.Time#suggestedFps value.

Source - core/Game.js, line 460

<readonly>height:integer

The current Game Height in pixels.

Do not modify this property directly: use Phaser.ScaleManager#setGameSize

  • eg. game.scale.setGameSize(width, height) - instead.

Default Value: - 600

Source - core/Game.js, line 140

<readonly>id:number

Phaser Game ID

Source - core/Game.js, line 101

input:Phaser.Input

Reference to the input manager

Source - core/Game.js, line 256

<readonly>isBooted:boolean

Whether the game engine is booted, aka available.

Source - core/Game.js, line 224

<readonly>isRunning:boolean

Is game running or paused?

Source - core/Game.js, line 230

load:Phaser.Loader

Reference to the assets loader.

Source - core/Game.js, line 261

lockRender:boolean

If false Phaser will automatically render the display list every update. If true the render loop will be skipped. You can toggle this value at run-time to gain exact control over when Phaser renders. This can be useful in certain types of game or application. Please note that if you don't render the display list then none of the game object transforms will be updated, so use this value carefully.

Source - core/Game.js, line 360

make:Phaser.GameObjectCreator

Reference to the GameObject Creator.

Source - core/Game.js, line 246

math:Phaser.Math

Reference to the math helper.

Source - core/Game.js, line 266

<readonly>multiTexture:boolean

Has support for Multiple bound Textures in WebGL been enabled? This is a read-only property. To set it you need to either specify Phaser.WEBGL_MULTI as the renderer type, or use the Game Configuration object with the property multiTexture set to true. It has to be enabled before Pixi boots, and cannot be changed after the game is running. Once enabled, take advantage of it via the game.renderer.setTexturePriority method.

Source - core/Game.js, line 187

net:Phaser.Net

Reference to the network class.

Source - core/Game.js, line 271

onBlur:Phaser.Signal

This event is fired when the game no longer has focus (typically on pagehide).

Source - core/Game.js, line 396

onFocus:Phaser.Signal

This event is fired when the game has focus (typically on page show).

Source - core/Game.js, line 401

onPause:Phaser.Signal

This event is fired when the game pauses.

Source - core/Game.js, line 386

onResume:Phaser.Signal

This event is fired when the game resumes from a paused state.

Source - core/Game.js, line 391

<readonly>parent:string|HTMLElement

The Game's DOM parent (or name thereof), if any, as set when the game was created. The actual parent can be found in game.canvas.parentNode. Setting this has no effect after Phaser.ScaleManager is booted.

Type:

  • string| HTMLElement

Source - core/Game.js, line 118

particles:Phaser.Particles

The Particle Manager.

Source - core/Game.js, line 346

paused:boolean

The paused state of the Game. A paused game doesn't update any of its subsystems. When a game is paused the onPause event is dispatched. When it is resumed the onResume event is dispatched. Gets and sets the paused state of the Game.

Source - core/Game.js, line 1258

<readonly>pendingStep:boolean

An internal property used by enableStep, but also useful to query from your own game objects.

Source - core/Game.js, line 374

physics:Phaser.Physics

Reference to the physics manager.

Source - core/Game.js, line 306

physicsConfig:object

The Phaser.Physics.World configuration object.

Source - core/Game.js, line 111

plugins:Phaser.PluginManager

Reference to the plugin manager.

Source - core/Game.js, line 311

preserveDrawingBuffer:boolean

The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering.

Source - core/Game.js, line 193

<internal>raf:Phaser.RequestAnimationFrame

Automatically handles the core game loop via requestAnimationFrame or setTimeout

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 236

<internal>renderer:PIXI.CanvasRenderer|PIXI.WebGLRenderer

The Pixi Renderer.

Type:

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 207

<readonly>renderType:number

The Renderer this game will use. Either Phaser.AUTO, Phaser.CANVAS, Phaser.WEBGL, Phaser.WEBGL_MULTI or Phaser.HEADLESS. After the game boots, renderType reflects the renderer in use: AUTO changes to CANVAS or WEBGL and WEBGL_MULTI changes to WEBGL. HEADLESS skips render hooks but not preRender or postRender; set lockRender to skip those as well.

Source - core/Game.js, line 213

<readonly>resolution:integer

The resolution of your game, as a ratio of canvas pixels to game pixels. This value is read only, but can be changed at start time it via a game configuration object.

Default Value: - 1

Source - core/Game.js, line 149

rnd:Phaser.RandomDataGenerator

Instance of repeatable random data generator helper.

Source - core/Game.js, line 316

scale:Phaser.ScaleManager

The game scale manager.

Source - core/Game.js, line 276

sound:Phaser.SoundManager

Reference to the sound manager.

Source - core/Game.js, line 281

stage:Phaser.Stage

Reference to the stage.

Source - core/Game.js, line 286

state:Phaser.StateManager

The StateManager.

Source - core/Game.js, line 218

<readonly>stepCount:number

When stepping is enabled this contains the current step cycle.

Source - core/Game.js, line 381

<readonly>stepping:boolean

Enable core loop stepping with Game.enableStep().

Source - core/Game.js, line 367

time:Phaser.Time

Reference to the core game clock.

Source - core/Game.js, line 291

transparent:boolean

Use a transparent canvas background or not.

Source - core/Game.js, line 167

tweens:Phaser.TweenManager

Reference to the tween manager.

Source - core/Game.js, line 296

<internal>updatesThisFrame:integer

Number of logic updates expected to occur this render frame; will be 1 unless there are catch-ups required (and allowed).

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 428

<readonly>width:integer

The current Game Width in pixels.

Do not modify this property directly: use Phaser.ScaleManager#setGameSize

  • eg. game.scale.setGameSize(width, height) - instead.

Default Value: - 800

Source - core/Game.js, line 129

world:Phaser.World

Reference to the world.

Source - core/Game.js, line 301

<internal> boot()

Initialize engine sub modules and start the game.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 610

destroy()

Nukes the entire game from orbit.

Calls destroy on Game.state, Game.sound, Game.scale, Game.stage, Game.input, Game.physics and Game.plugins.

Then sets all of those local handlers to null, destroys the renderer, removes the canvas from the DOM and resets the PIXI default renderer.

Source - core/Game.js, line 1099

disableStep()

Disables core game loop stepping.

Source - core/Game.js, line 1074

enableStep()

Enable core game loop stepping. When enabled you must call game.step() directly (perhaps via a DOM button?) Calling step will advance the game loop by one frame. This is extremely useful for hard to track down errors!

Source - core/Game.js, line 1060

<internal>focusGain(event)

Called by the Stage visibility handler.

Parameters:

Name

Type

Description

event

object

The DOM event that caused the game to pause, if any.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 1236

<internal>focusLoss(event)

Called by the Stage visibility handler.

Parameters:

Name

Type

Description

event

object

The DOM event that caused the game to pause, if any.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 1218

<internal>gamePaused(event)

Called by the Stage visibility handler.

Parameters:

Name

Type

Description

event

object

The DOM event that caused the game to pause, if any.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 1152

<internal>gameResumed(event)

Called by the Stage visibility handler.

Parameters:

Name

Type

Description

event

object

The DOM event that caused the game to pause, if any.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 1184

<internal>parseConfig()

Parses a Game configuration object.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 525

<internal>setUpRenderer()

Checks if the device is capable of using the requested renderer and sets it up or an alternative if not.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 766

<internal>showDebugHeader()

Displays a Phaser version debug header in the console.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 699

step()

When stepping is enabled you must call this function directly (perhapsvia a DOM button?) to advance the game loop by one frame. This is extremely useful to hard to track down errors! Use the internal stepCount property to monitor progress.

Source - core/Game.js, line 1086

<internal>update(time)

The core game loop.

Parameters:

Name

Type

Description

time

number

The current time as provided by RequestAnimationFrame.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 876

<internal>updateLogic(timeStep)

Updates all logic subsystems in Phaser. Called automatically by Game.update.

Parameters:

Name

Type

Description

timeStep

number

The current timeStep value as determined by Game.update.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 976

<internal>updateRender(elapsedTime)

Runs the Render cycle. It starts by calling State.preRender. In here you can do any last minute adjustments of display objects as required. It then calls the renderer, which renders the entire display list, starting from the Stage object and working down. It then calls plugin.render on any loaded plugins, in the order in which they were enabled. After this State.render is called. Any rendering that happens here will take place on-top of the display list. Finally plugin.postRender is called on any loaded plugins, in the order in which they were enabled. This method is called automatically by Game.update, you don't need to call it directly. Should you wish to have fine-grained control over when Phaser renders then use the Game.lockRender boolean. Phaser will only render when this boolean is false.

Parameters:

Name

Type

Description

elapsedTime

number

The time elapsed since the last update.

Internal: - This member is internal (protected) and may be modified or removed in the future.

Source - core/Game.js, line 1023