Implement and register this class with a b2World to provide debug drawing of physics entities in your game.

Although Box2D is a physics engine and therefore has nothing to do with drawing, Box2dFlash provides such methods for debugging which are defined in the b2DebugDraw class. In Box2dWeb, a b2DebugDraw takes a canvas-context instead of a Sprite:

var debugDraw = new Box2D.Dynamics.b2DebugDraw();
debugDraw.SetSprite(document.GetElementsByTagName("canvas")[0].getContext("2d"));

Constructors

Properties

e_aabbBit: number

Draw axis aligned bounding boxes.

e_centerOfMassBit: number

Draw center of mass frame.

e_controllerBit: number

Draw controllers.

e_jointBit: number

Draw joint connections.

e_pairBit: number

Draw broad-phase pairs.

e_shapeBit: number

Draw shapes.

Methods

  • Append flags to the current flags.

    Parameters

    • flags: number

      Flags to add.

    Returns void

  • Clear flags from the current flags.

    Parameters

    • flags: number

      flags to clear.

    Returns void

  • Draw a closed polygon provided in CCW order.

    Parameters

    • vertices: b2Vec2[]

      Polygon verticies.

    • vertexCount: number

      Number of vertices in the polygon, usually vertices.length.

    • color: b2Color

      Polygon draw color.

    Returns void

  • Draw a solid closed polygon provided in CCW order.

    Parameters

    • vertices: b2Vec2[]

      Polygon verticies.

    • vertexCount: number

      Number of vertices in the polygon, usually vertices.length.

    • color: b2Color

      Polygon draw color.

    Returns void

  • Get the alpha value used for lines.

    Returns number

    Alpha value used for drawing lines.

  • Get the alpha value used for fills.

    Returns number

    Alpha value used for drawing fills.

  • Get the HTML Canvas Element for drawing.

    Returns CanvasRenderingContext2D

    The HTML Canvas Element used for debug drawing.

    box2dflash uses Sprite object, box2dweb uses CanvasRenderingContext2D, that is why this function is called GetSprite().

  • Get the scale used for drawing XForms.

    Returns number

    Scale for drawing transforms.

  • Set the alpha value used for lines.

    Parameters

    • alpha: number

      Alpha value for drawing lines.

    Returns void

  • Set the draw scale.

    Parameters

    • drawScale: number

      Draw scale ratio.

    Returns void

  • Set the alpha value used for fills.

    Parameters

    • alpha: number

      Alpha value for drawing fills.

    Returns void

  • Set the drawing flags.

    Parameters

    • flags: number

      Sets the drawing flags.

    Returns void

  • Set the line thickness.

    Parameters

    • lineThickness: number

      The new line thickness.

    Returns void

  • Set the HTML Canvas Element for drawing.

    Parameters

    • canvas: CanvasRenderingContext2D

      HTML Canvas Element to draw debug information to.

    Returns void

    box2dflash uses Sprite object, box2dweb uses CanvasRenderingContext2D, that is why this function is called SetSprite().

  • Set the scale used for drawing XForms.

    Parameters

    • xformScale: number

      The transform scale.

    Returns void