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 | Anti-alias graphics. |
physicsConfig |
object |
<optional> |
null | A physics configuration object to pass to the Physics world on creation. |
- Source:
Members
-
add
-
- Source:
Properties:
Name Type Description add
Phaser.GameObjectFactory Reference to the GameObject Factory.
-
antialias
-
- Default Value:
- true
- Source:
Properties:
Name Type Description antialias
boolean Anti-alias graphics (in WebGL this helps with edges, in Canvas2D it retains pixel-art quality).
-
cache
-
- Default Value:
- null
- Source:
Properties:
Name Type Description cache
Phaser.Cache Reference to the assets cache.
-
camera
-
- Source:
Properties:
Name Type Description camera
Phaser.Physics.PhysicsManager A handy reference to world.camera.
-
canvas
-
- Source:
Properties:
Name Type Description canvas
HTMLCanvasElement A handy reference to renderer.view, the canvas that the game is being rendered in to.
-
config
-
- Source:
Properties:
Name Type Description config
object The Phaser.Game configuration object.
-
context
-
- Source:
Properties:
Name Type Description context
Context A handy reference to renderer.context (only set for CANVAS games, not WebGL)
-
debug
-
- Source:
Properties:
Name Type Description debug
Phaser.Utils.Debug A set of useful debug utilitie.
-
device
-
- Source:
Properties:
Name Type Description device
Phaser.Device Contains device information and capabilities.
-
height
-
- Default Value:
- 600
- Source:
Properties:
Name Type Description height
number The Game height (in pixels).
-
id
-
- Source:
Properties:
Name Type Description id
number Phaser Game ID (for when Pixi supports multiple instances).
-
input
-
- Default Value:
- null
- Source:
Properties:
Name Type Description input
Phaser.Input Reference to the input manager
-
isBooted
-
- Default Value:
- false
- Source:
Properties:
Name Type Description isBooted
boolean Whether the game engine is booted, aka available.
-
isRunning
-
- Default Value:
- false
- Source:
Properties:
Name Type Description id
boolean Is game running or paused?
-
load
-
- Default Value:
- null
- Source:
Properties:
Name Type Description load
Phaser.Loader Reference to the assets loader.
-
math
-
- Source:
Properties:
Name Type Description math
Phaser.Math Reference to the math helper.
-
net
-
- Source:
Properties:
Name Type Description net
Phaser.Net Reference to the network class.
-
parent
-
- Source:
Properties:
Name Type Description parent
HTMLElement The Games DOM parent.
-
particles
-
- Source:
Properties:
Name Type Description particles
Phaser.Particles The Particle Manager.
-
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.
- Source:
Properties:
Name Type Description paused
boolean Gets and sets the paused state of the Game.
-
<readonly> pendingStep
-
- Default Value:
- false
- Source:
Properties:
Name Type Description stepping
boolean An internal property used by enableStep, but also useful to query from your own game objects.
-
physics
-
- Source:
Properties:
Name Type Description physics
Phaser.Physics.World Reference to the physics world.
-
physicsConfig
-
- Source:
Properties:
Name Type Description physicsConfig
object The Phaser.Physics.World configuration object.
-
raf
-
- Source:
Properties:
Name Type Description raf
Phaser.RequestAnimationFrame Automatically handles the core game loop via requestAnimationFrame or setTimeout
-
renderer
-
- Source:
Properties:
Name Type Description renderer
number The Pixi Renderer
-
renderType
-
- Source:
Properties:
Name Type Description renderType
number The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL.
-
rnd
-
- Source:
Properties:
Name Type Description rnd
Phaser.RandomDataGenerator Instance of repeatable random data generator helper.
-
scale
-
- Source:
Properties:
Name Type Description scale
Phaser.StageScaleMode The game scale manager.
-
sound
-
- Source:
Properties:
Name Type Description sound
Phaser.SoundManager Reference to the sound manager.
-
stage
-
- Source:
Properties:
Name Type Description stage
Phaser.Stage Reference to the stage.
-
state
-
- Source:
Properties:
Name Type Description state
number The StateManager.
-
<readonly> stepCount
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description stepCount
number When stepping is enabled this contains the current step cycle.
-
<readonly> stepping
-
- Default Value:
- false
- Source:
Properties:
Name Type Description stepping
boolean Enable core loop stepping with Game.enableStep().
-
time
-
- Source:
Properties:
Name Type Description time
Phaser.TimeManager Reference to game clock.
-
transparent
-
- Default Value:
- false
- Source:
Properties:
Name Type Description transparent
boolean Use a transparent canvas background or not.
-
tweens
-
- Source:
Properties:
Name Type Description tweens
Phaser.TweenManager Reference to the tween manager.
-
width
-
- Default Value:
- 800
- Source:
Properties:
Name Type Description width
number The Game width (in pixels).
-
world
-
- Source:
Properties:
Name Type Description world
Phaser.World Reference to the world.
Methods
-
<protected> boot()
-
Initialize engine sub modules and start the game.
- Source:
-
destroy()
-
Nuke the entire game from orbit
- Source:
-
disableStep()
-
Disables core game loop stepping.
- Source:
-
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 to hard to track down errors!
- Source:
-
<protected> loadComplete()
-
Called when the load has finished, after preload was run.
- Source:
-
<protected> parseConfig()
-
Parses a Game configuration object.
- Source:
-
<protected> parseDimension()
-
Get dimension.
- 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:
-
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:
-
<protected> update(time)
-
The core game loop.
Parameters:
Name Type Description time
number The current time as provided by RequestAnimationFrame.
- Source: