physics.setDrawMode()

Type Function
Library physics.*
Return value none
Revision 2017.3060
Keywords physics, draw mode, debug, hybrid
See also physics.start()

Overview

Sets one of three possible "rendering modes" for the physics engine. While this feature will run on devices, it's most useful in the Corona Simulator when debugging unexpected physics engine behavior.

Physics data is displayed using colored vector graphics which reflect different object types and attributes. See the Physics Bodies guide for details.

Gotchas

When working with Corona display groups and Box2D, it's important to remember that Box2D expects all physics objects to share a global coordinate system. Both grouped and ungrouped display objects will work well since they will share the internal coordinates of that group. However, unexpected results will occur if physical objects are added to different display groups and those groups are moved, scaled, or rotated independently of each other. As a general rule, do not alter the position, scale, or rotation of display groups that contain physics objects.

Syntax

physics.setDrawMode( mode )
mode (required)

String. The draw mode, which can be any of the following:

  • "normal"
  • "hybrid"
  • "debug"

Example

physics.setDrawMode( "normal" )  --the default Corona renderer, with no collision outlines
physics.setDrawMode( "hybrid" )  --overlays collision outlines on normal display objects
physics.setDrawMode( "debug" )   --shows collision engine outlines only