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)

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 (canvas or webgl)

parent HTMLElement <optional>
''

The Games DOM parent.

state any <optional>
null

Description.

transparent boolean <optional>
false

Use a transparent canvas background or not.

antialias boolean <optional>
true

Anti-alias graphics.

Source:

Members

add

Properties:
Name Type Description
add Phaser.GameObjectFactory

Reference to the GameObject Factory.

Default Value:
  • null
Source:

antialias

Properties:
Name Type Description
antialias boolean

Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality).

Source:

cache

Properties:
Name Type Description
cache Phaser.Cache

Reference to the assets cache.

Default Value:
  • null
Source:

camera

Properties:
Name Type Description
camera Phaser.Physics.PhysicsManager

A handy reference to world.camera.

Default Value:
  • null
Source:

canvas

Properties:
Name Type Description
canvas HTMLCanvasElement

A handy reference to renderer.view.

Default Value:
  • null
Source:

context

Properties:
Name Type Description
context Context

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

Default Value:
  • null
Source:

debug

Properties:
Name Type Description
debug Phaser.Utils.Debug

A set of useful debug utilitie.

Default Value:
  • null
Source:

device

Properties:
Name Type Description
device Phaser.Device

Contains device information and capabilities.

Default Value:
  • null
Source:

height

Properties:
Name Type Description
height number

The Game height (in pixels).

Source:

id

Properties:
Name Type Description
id number

Phaser Game ID (for when Pixi supports multiple instances).

Source:

input

Properties:
Name Type Description
input Phaser.Input

Reference to the input manager

Default Value:
  • null
Source:

isBooted

Properties:
Name Type Description
isBooted boolean

Whether the game engine is booted, aka available.

Default Value:
  • false
Source:

isRunning

Properties:
Name Type Description
id boolean

Is game running or paused?

Default Value:
  • false
Source:

load

Properties:
Name Type Description
load Phaser.Loader

Reference to the assets loader.

Default Value:
  • null
Source:

math

Properties:
Name Type Description
math Phaser.GameMath

Reference to the math helper.

Default Value:
  • null
Source:

net

Properties:
Name Type Description
net Phaser.Net

Reference to the network class.

Default Value:
  • null
Source:

parent

Properties:
Name Type Description
parent HTMLElement

The Games DOM parent.

Source:

particles

Properties:
Name Type Description
particles Phaser.Particles

The Particle Manager.

Default Value:
  • null
Source:

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:

physics

Properties:
Name Type Description
physics Phaser.Physics.PhysicsManager

Reference to the physics manager.

Default Value:
  • null
Source:

raf

Properties:
Name Type Description
raf Phaser.RequestAnimationFrame

Automatically handles the core game loop via requestAnimationFrame or setTimeout

Default Value:
  • null
Source:

renderer

Properties:
Name Type Description
renderer number

The Pixi Renderer

Default Value:
  • null
Source:

renderType

Properties:
Name Type Description
renderType number

The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL.

Source:

rnd

Properties:
Name Type Description
rnd Phaser.RandomDataGenerator

Instance of repeatable random data generator helper.

Default Value:
  • null
Source:

sound

Properties:
Name Type Description
sound Phaser.SoundManager

Reference to the sound manager.

Default Value:
  • null
Source:

stage

Properties:
Name Type Description
stage Phaser.Stage

Reference to the stage.

Default Value:
  • null
Source:

state

Properties:
Name Type Description
state number

The StateManager.

Source:

time

Properties:
Name Type Description
time Phaser.TimeManager

Reference to game clock.

Default Value:
  • null
Source:

transparent

Properties:
Name Type Description
transparent boolean

Use a transparent canvas background or not.

Source:

tweens

Properties:
Name Type Description
tweens Phaser.TweenManager

Reference to the tween manager.

Default Value:
  • null
Source:

width

Properties:
Name Type Description
width number

The Game width (in pixels).

Source:

world

Properties:
Name Type Description
world Phaser.World

Reference to the world.

Default Value:
  • null
Source:

Methods

<protected> boot()

Initialize engine sub modules and start the game.

Source:

destroy()

Nuke the entire game from orbit

Source:

<protected> loadComplete()

Called when the load has finished, after preload was run.

Source:

<protected> setUpRenderer()

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

Source:

<protected> showDebugHeader()

Displays a Phaser version debug header in the console.

Source:

<protected> update(time)

The core game loop.

Parameters:
Name Type Description
time number

The current time as provided by RequestAnimationFrame.

Source:
Phaser Copyright © 2012-2013 Photon Storm Ltd.
Documentation generated by JSDoc 3.3.0-dev on Fri Nov 01 2013 18:16:11 GMT-0000 (GMT) using the DocStrap template.