This method enables rendering of the Rope vertices to the given Graphics instance.
If you enable this feature, you must call Graphics.clear()
in your Scene update
,
otherwise the Graphics instance you provide to debug will fill-up with draw calls,
eventually crashing the browser. This is not done automatically to allow you to debug
draw multiple Rope objects to a single Graphics instance.
The Rope class has a built-in debug rendering callback Rope.renderDebugVerts
, however
you can also provide your own callback to be used instead. Do this by setting the callback
parameter.
The callback is invoked once per render and sent the following parameters:
callback(src, meshLength, verts)
src
is the Rope instance being debugged.
meshLength
is the number of mesh vertices in total.
verts
is an array of the translated vertex coordinates.
If using your own callback you do not have to provide a Graphics instance to this method.
To disable debug rendering, to either your own callback or the built-in one, call this method with no arguments.
name | type | arguments | description |
---|---|---|---|
graphic | Phaser.GameObjects.Graphics | <optional> |
The Graphic instance to render to if using the built-in callback. |
callback | function | <optional> |
The callback to invoke during debug render. Leave as undefined to use the built-in callback. |
This Game Object instance.