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 | string |
<optional> |
800 | The width of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage width of the parent container, or the browser window if no parent is given. |
height |
number | string |
<optional> |
600 | The height of your game in game pixels. If given as a string the value must be between 0 and 100 and will be used as the percentage height of the parent container, or the browser window if no parent is given. |
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:
Members
-
add
-
- Source:
Properties:
Name Type Description add
Phaser.GameObjectFactory Reference to the Phaser.GameObjectFactory.
-
antialias
-
- Default Value:
- true
- Source:
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.
-
cache
-
- Source:
Properties:
Name Type Description cache
Phaser.Cache Reference to the assets cache.
-
camera
-
- Source:
Properties:
Name Type Description camera
Phaser.Camera 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
CanvasRenderingContext2D 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 calculated game height in pixels.
-
id
-
- Source:
Properties:
Name Type Description id
number Phaser Game ID (for when Pixi supports multiple instances).
-
input
-
- 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
-
- Source:
Properties:
Name Type Description load
Phaser.Loader Reference to the assets loader.
-
make
-
- Source:
Properties:
Name Type Description make
Phaser.GameObjectCreator Reference to the GameObject Creator.
-
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.
-
onBlur
-
- Source:
Properties:
Name Type Description onBlur
Phaser.Signal This event is fired when the game no longer has focus (typically on page hide).
-
onFocus
-
- Source:
Properties:
Name Type Description onFocus
Phaser.Signal This event is fired when the game has focus (typically on page show).
-
onPause
-
- Source:
Properties:
Name Type Description onPause
Phaser.Signal This event is fired when the game pauses.
-
onResume
-
- Source:
Properties:
Name Type Description onResume
Phaser.Signal This event is fired when the game resumes from a paused state.
-
parent
-
- Source:
Properties:
Name Type Description parent
string | 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 pendingStep
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 Reference to the physics manager.
-
physicsConfig
-
- Source:
Properties:
Name Type Description physicsConfig
object The Phaser.Physics.World configuration object.
-
preserveDrawingBuffer
-
- Default Value:
- false
- Source:
Properties:
Name Type Description preserveDrawingBuffer
boolean The value of the preserveDrawingBuffer flag affects whether or not the contents of the stencil buffer is retained after rendering.
-
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
PIXI.CanvasRenderer | PIXI.WebGLRenderer The Pixi Renderer.
-
renderType
-
- Source:
Properties:
Name Type Description renderType
number The Renderer this game will use. Either Phaser.AUTO, Phaser.CANVAS or Phaser.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.ScaleManager 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
Phaser.StateManager 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.Time Reference to the core 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 calculated 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()
-
Nukes 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 for hard to track down errors!
- Source:
-
<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:
-
<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:
-
<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:
-
<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:
-
<protected> parseConfig()
-
Parses a Game configuration object.
- 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: