Phaser API Documentation

enableDebug(gameObject, [color])


Creates an Input Debug Shape for the given Game Object.

The Game Object must have already been enabled for input prior to calling this method.

This is intended to assist you during development and debugging.

Debug Shapes can only be created for Game Objects that are using standard Phaser Geometry for input, including: Circle, Ellipse, Line, Polygon, Rectangle and Triangle.

Game Objects that are using their automatic hit areas are using Rectangles by default, so will also work.

The Debug Shape is created and added to the display list and is then kept in sync with the Game Object it is connected with. Should you need to modify it yourself, such as to hide it, you can access it via the Game Object property: GameObject.input.hitAreaDebug.

Calling this method on a Game Object that already has a Debug Shape will first destroy the old shape, before creating a new one. If you wish to remove the Debug Shape entirely, you should call the method InputPlugin.removeDebug.

Note that the debug shape will only show the outline of the input area. If the input test is using a pixel perfect check, for example, then this is not displayed. If you are using a custom shape, that doesn't extend one of the base Phaser Geometry objects, as your hit area, then this method will not work.


name type arguments Default description
gameObject Phaser.GameObjects.GameObject

The Game Object to create the input debug shape for.

color number <optional> 0x00ff00

The outline color of the debug shape.


This Input Plugin.

Since: 3.19.0