new Debug(game)
A collection of methods for displaying debug information about game objects. Phaser.Debug requires a CANVAS game type in order to render, so if you've got your game set to use Phaser.AUTO then swap it for Phaser.CANVAS to ensure WebGL doesn't kick in, then the Debug functions will all display.
Parameters:
Name | Type | Description |
---|---|---|
game |
Phaser.Game | A reference to the currently running game. |
- Source:
Members
-
columnWidth
-
- Source:
Properties:
Name Type Description columnWidth
number The spacing between columns.
-
context
-
- Source:
Properties:
Name Type Description context
Context The canvas context on which to render the debug information.
-
currentAlpha
-
- Default Value:
- 1
- Source:
Properties:
Name Type Description currentAlpha
number The current alpha the debug information will be rendered at.
-
currentX
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description currentX
Context The current X position the debug information will be rendered at.
-
currentY
-
- Default Value:
- 0
- Source:
Properties:
Name Type Description currentY
number The current Y position the debug information will be rendered at.
-
font
-
- Default Value:
- '14px Courier'
- Source:
Properties:
Name Type Description font
string The font that the debug information is rendered in.
-
game
-
- Source:
Properties:
Name Type Description game
Phaser.Game A reference to the currently running Game.
-
lineHeight
-
- Source:
Properties:
Name Type Description lineHeight
number The line height between the debug text.
-
renderShadow
-
- Source:
Properties:
Name Type Description renderShadow
boolean Should the text be rendered with a slight shadow? Makes it easier to read on different types of background.
Methods
-
line(text, x, y)
-
Internal method that outputs a single line of text.
Parameters:
Name Type Argument Description text
string The line of text to draw.
x
number <optional>
The X value the debug info will start from.
y
number <optional>
The Y value the debug info will start from.
- Source:
-
renderBodyInfo(sprite, x, y, color)
-
Render Sprite Body Physics Data as text.
Parameters:
Name Type Argument Default Description sprite
Phaser.Sprite The sprite to be rendered.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderCameraInfo(camera, x, y, color)
-
Render camera information including dimensions and location.
Parameters:
Name Type Argument Default Description camera
Phaser.Camera Description.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderCircle(circle, color)
-
Renders a Circle.
Parameters:
Name Type Argument Description circle
Phaser.Circle The Circle to render.
color
string <optional>
Color of the debug info to be rendered (format is css color string).
- Source:
-
renderInputInfo(x, y, color)
-
Render debug information about the Input object.
Parameters:
Name Type Argument Default Description x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderLine(line, color)
-
Renders a Line object in the given color.
Parameters:
Name Type Argument Default Description line
Phaser.Line The Line to render.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderLineInfo(line, x, y, color)
-
Renders Line information in the given color.
Parameters:
Name Type Argument Default Description line
Phaser.Line The Line to render.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderPhysicsBody(body, color)
-
Parameters:
Name Type Argument Default Description body
array color
string <optional>
'rgb(255,255,255)' The color the polygon is stroked in.
- Source:
-
renderPixel(x, y, color)
-
Renders a single pixel.
Parameters:
Name Type Argument Description x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
Color of the debug info to be rendered (format is css color string).
- Source:
-
renderPoint(point, color)
-
Renders a Point object.
Parameters:
Name Type Argument Description point
Phaser.Point The Point to render.
color
string <optional>
Color of the debug info to be rendered (format is css color string).
- Source:
-
renderPointer(pointer, hideIfUp, downColor, upColor, color)
-
Renders the Pointer.circle object onto the stage in green if down or red if up along with debug text.
Parameters:
Name Type Argument Default Description pointer
Phaser.Pointer Description.
hideIfUp
boolean <optional>
false Doesn't render the circle if the pointer is up.
downColor
string <optional>
'rgba(0,255,0,0.5)' The color the circle is rendered in if down.
upColor
string <optional>
'rgba(255,0,0,0.5)' The color the circle is rendered in if up (and hideIfUp is false).
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderPointInfo(sprite, x, y, color)
-
Renders Point coordinates in the given color.
Parameters:
Name Type Argument Default Description sprite
Phaser.Point Description.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderPolygon(polygon, color)
-
Parameters:
Name Type Argument Default Description polygon
array color
string <optional>
'rgb(255,255,255)' The color the polygon is stroked in.
- Source:
-
renderQuadTree(quadtree, color)
-
Visually renders a QuadTree to the display.
Parameters:
Name Type Description quadtree
Phaser.QuadTree The quadtree to render.
color
string The color of the lines in the quadtree.
- Source:
-
renderRectangle(rect, color)
-
Renders a Rectangle.
Parameters:
Name Type Argument Description rect
Phaser.Rectangle The Rectangle to render.
color
string <optional>
Color of the debug info to be rendered (format is css color string).
- Source:
-
renderSoundInfo(sound, x, y, color)
-
Render Sound information, including decoded state, duration, volume and more.
Parameters:
Name Type Argument Default Description sound
Phaser.Sound The sound object to debug.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderSpriteBounds(sprite, color, fill)
-
Renders just the full Sprite bounds.
Parameters:
Name Type Argument Default Description sprite
Phaser.Sprite Description.
color
string <optional>
Color of the debug info to be rendered (format is css color string).
fill
boolean <optional>
false If false the bounds outline is rendered, if true the whole rectangle is rendered.
- Source:
-
renderSpriteBounds(sprite, color, fill)
-
Renders just the full Sprite bounds.
Parameters:
Name Type Argument Default Description sprite
Phaser.Sprite Description.
color
string <optional>
Color of the debug info to be rendered (format is css color string).
fill
boolean <optional>
false If false the bounds outline is rendered, if true the whole rectangle is rendered.
- Source:
-
renderSpriteCoords(line, x, y, color)
-
Renders the sprite coordinates in local, positional and world space.
Parameters:
Name Type Argument Default Description line
Phaser.Sprite The sprite to inspect.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderSpriteCorners(sprite, showText, showBounds, color)
-
Renders the corners and point information of the given Sprite.
Parameters:
Name Type Argument Default Description sprite
Phaser.Sprite The sprite to be rendered.
showText
boolean <optional>
false If true the x/y coordinates of each point will be rendered.
showBounds
boolean <optional>
false If true the bounds will be rendered over the top of the sprite.
color
string <optional>
'rgb(255,0,255)' The color the text is rendered in.
- Source:
-
renderSpriteInfo(sprite, x, y, color)
-
Render debug infos (including name, bounds info, position and some other properties) about the Sprite.
Parameters:
Name Type Argument Default Description sprite
Phaser.Sprite Description.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderSpriteInputInfo(sprite, x, y, color)
-
Render Sprite Input Debug information.
Parameters:
Name Type Argument Default Description sprite
Phaser.Sprite The sprite to be rendered.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
'rgb(255,255,255)' color of the debug info to be rendered. (format is css color string).
- Source:
-
renderText(text, x, y, color, font)
-
Render text.
Parameters:
Name Type Argument Description text
string The line of text to draw.
x
number X position of the debug info to be rendered.
y
number Y position of the debug info to be rendered.
color
string <optional>
Color of the debug info to be rendered (format is css color string).
font
string The font of text to draw.
- Source:
-
splitline(text)
-
Internal method that outputs a single line of text split over as many columns as needed, one per parameter.
Parameters:
Name Type Description text
string The text to render. You can have as many columns of text as you want, just pass them as additional parameters.
- Source:
-
start(x, y, color, columnWidth)
-
Internal method that resets and starts the debug output values.
Parameters:
Name Type Argument Default Description x
number <optional>
0 The X value the debug info will start from.
y
number <optional>
0 The Y value the debug info will start from.
color
string <optional>
'rgb(255,255,255)' The color the debug text will drawn in.
columnWidth
number <optional>
0 The spacing between columns.
- Source:
-
stop()
-
Internal method that stops the debug output.
- Source: