# Class: Game

## Phaser. Game

This is where the magic happens. The Game object is the heart of your game, providing quick access to common functions and handling the boot process. "Hell, there are no rules here - we're trying to accomplish something." Thomas A. Edison

#### new Game(width, height, renderer, parent, state, transparent, antialias, physicsConfig)

  Game constructor

  Instantiate a new <code>Phaser.Game</code> object.

  ##### Parameters:

  Name | Type | Argument | Default | Description
  --- | --- | --- | --- | ---
  `width` | number | <optional> | 800 | The width of your game in game pixels.
  `height` | number | <optional> | 600 | The height of your game in game pixels.
  `renderer` | number | <optional> | Phaser.AUTO | Which renderer to use: Phaser.AUTO will auto-detect, Phaser.WEBGL, Phaser.CANVAS or Phaser.HEADLESS (no rendering at all).
  `parent` | string | HTMLElement | <optional> | '' | The DOM element into which this games canvas will be injected. Either a DOM ID (string) or the element itself.
  `state` | object | <optional> | null | The default state object. A object consisting of Phaser.State functions (preload, create, update, render) or null.
  `transparent` | boolean | <optional> | false | Use a transparent canvas background or not.
  `antialias` | boolean | <optional> | true | Draw all image textures anti-aliased or not. The default is for smooth textures, but disable if your game features pixel art.
  `physicsConfig` | object | <optional> | null | A physics configuration object to pass to the Physics world on creation.

  Source:
    - core/Game.js, line 26

### Members

#### add

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `add` | Phaser.GameObjectFactory | Reference to the Phaser.GameObjectFactory.

  Source:
    - core/Game.js, line 108

#### antialias

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `antialias` | boolean | Anti-alias graphics. By default scaled images are smoothed in Canvas and WebGL, set anti-alias to false to disable this globally.

  Default Value:
    - true
  Source:
    - core/Game.js, line 71

#### cache

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `cache` | Phaser.Cache | Reference to the assets cache.

  Source:
    - core/Game.js, line 118

#### camera

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `camera` | Phaser.Camera | A handy reference to world.camera.

  Source:
    - core/Game.js, line 188

#### canvas

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `canvas` | HTMLCanvasElement | A handy reference to renderer.view, the canvas that the game is being rendered in to.

  Source:
    - core/Game.js, line 193

#### config

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `config` | object | The Phaser.Game configuration object.

  Source:
    - core/Game.js, line 36

#### context

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `context` | CanvasRenderingContext2D | A handy reference to renderer.context (only set for CANVAS games, not WebGL)

  Source:
    - core/Game.js, line 198

#### debug

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `debug` | Phaser.Utils.Debug | A set of useful debug utilitie.

  Source:
    - core/Game.js, line 203

#### device

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `device` | Phaser.Device | Contains device information and capabilities.

  Source:
    - core/Game.js, line 183

#### height

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `height` | number | The Game height (in pixels).

  Default Value:
    - 600
  Source:
    - core/Game.js, line 59

#### id

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `id` | number | Phaser Game ID (for when Pixi supports multiple instances).

  Source:
    - core/Game.js, line 31

#### input

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `input` | Phaser.Input | Reference to the input manager

  Source:
    - core/Game.js, line 123

#### isBooted

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `isBooted` | boolean | Whether the game engine is booted, aka available.

  Default Value:
    - false
  Source:
    - core/Game.js, line 92

#### isRunning

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `id` | boolean | Is game running or paused?

  Default Value:
    - false
  Source:
    - core/Game.js, line 98

#### load

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `load` | Phaser.Loader | Reference to the assets loader.

  Source:
    - core/Game.js, line 128

#### make

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `make` | Phaser.GameObjectCreator | Reference to the GameObject Creator.

  Source:
    - core/Game.js, line 113

#### math

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `math` | Phaser.Math | Reference to the math helper.

  Source:
    - core/Game.js, line 133

#### net

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `net` | Phaser.Net | Reference to the network class.

  Source:
    - core/Game.js, line 138

#### onBlur

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onBlur` | Phaser.Signal | This event is fired when the game no longer has focus (typically on page hide).

  Source:
    - core/Game.js, line 244

#### onFocus

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onFocus` | Phaser.Signal | This event is fired when the game has focus (typically on page show).

  Source:
    - core/Game.js, line 249

#### onPause

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onPause` | Phaser.Signal | This event is fired when the game pauses.

  Source:
    - core/Game.js, line 234

#### onResume

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `onResume` | Phaser.Signal | This event is fired when the game resumes from a paused state.

  Source:
    - core/Game.js, line 239

#### parent

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `parent` | string | HTMLElement | The Games DOM parent.

  Source:
    - core/Game.js, line 47

#### particles

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `particles` | Phaser.Particles | The Particle Manager.

  Source:
    - core/Game.js, line 208

#### paused

  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.

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `paused` | boolean | Gets and sets the paused state of the Game.

  Source:
    - core/Game.js, line 780

#### <readonly> pendingStep

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `pendingStep` | boolean | An internal property used by enableStep, but also useful to query from your own game objects.

  Default Value:
    - false
  Source:
    - core/Game.js, line 222

#### physics

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `physics` | Phaser.Physics | Reference to the physics manager.

  Source:
    - core/Game.js, line 173

#### physicsConfig

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `physicsConfig` | object | The Phaser.Physics.World configuration object.

  Source:
    - core/Game.js, line 41

#### raf

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `raf` | Phaser.RequestAnimationFrame | Automatically handles the core game loop via requestAnimationFrame or setTimeout

  Source:
    - core/Game.js, line 103

#### renderer

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `renderer` | PIXI.CanvasRenderer | PIXI.WebGLRenderer | The Pixi Renderer.

  Source:
    - core/Game.js, line 76

#### renderType

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `renderType` | number | The Renderer this game will use. Either Phaser.AUTO, Phaser.CANVAS or Phaser.WEBGL.

  Source:
    - core/Game.js, line 81

#### rnd

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `rnd` | Phaser.RandomDataGenerator | Instance of repeatable random data generator helper.

  Source:
    - core/Game.js, line 178

#### scale

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `scale` | Phaser.ScaleManager | The game scale manager.

  Source:
    - core/Game.js, line 143

#### sound

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `sound` | Phaser.SoundManager | Reference to the sound manager.

  Source:
    - core/Game.js, line 148

#### stage

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `stage` | Phaser.Stage | Reference to the stage.

  Source:
    - core/Game.js, line 153

#### state

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `state` | Phaser.StateManager | The StateManager.

  Source:
    - core/Game.js, line 86

#### <readonly> stepCount

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `stepCount` | number | When stepping is enabled this contains the current step cycle.

  Default Value:
    - 0
  Source:
    - core/Game.js, line 229

#### <readonly> stepping

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `stepping` | boolean | Enable core loop stepping with Game.enableStep().

  Default Value:
    - false
  Source:
    - core/Game.js, line 215

#### time

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `time` | Phaser.Time | Reference to the core game clock.

  Source:
    - core/Game.js, line 158

#### transparent

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `transparent` | boolean | Use a transparent canvas background or not.

  Default Value:
    - false
  Source:
    - core/Game.js, line 65

#### tweens

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `tweens` | Phaser.TweenManager | Reference to the tween manager.

  Source:
    - core/Game.js, line 163

#### width

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `width` | number | The Game width (in pixels).

  Default Value:
    - 800
  Source:
    - core/Game.js, line 53

#### world

  ##### Properties:

  Name | Type | Description
  --- | --- | ---
  `world` | Phaser.World | Reference to the world.

  Source:
    - core/Game.js, line 168

### Methods

#### <protected> boot()

  Initialize engine sub modules and start the game.

  Source:
    - core/Game.js, line 395

#### destroy()

  Nuke the entire game from orbit

  Source:
    - core/Game.js, line 680

#### disableStep()

  Disables core game loop stepping.

  Source:
    - core/Game.js, line 655

#### 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 641

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

  Source:
    - core/Game.js, line 761

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

  Source:
    - core/Game.js, line 746

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

  Source:
    - core/Game.js, line 705

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

  Source:
    - core/Game.js, line 725

#### <protected> parseConfig()

  Parses a Game configuration object.

  Source:
    - core/Game.js, line 328

#### <protected> setUpRenderer()

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

  Source:
    - core/Game.js, line 538

#### <protected> showDebugHeader()

  Displays a Phaser version debug header in the console.

  Source:
    - core/Game.js, line 476

#### step()

  When stepping is enabled you must call this function directly (perhaps via 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 667

#### <protected> update(time)

  The core game loop when in a paused state.

  ##### Parameters:

  Name | Type | Description
  --- | --- | ---
  `time` | number | The current time as provided by RequestAnimationFrame.

  Source:
    - core/Game.js, line 588