Options
All
  • Public
  • Public/Protected
  • All
Menu

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

example

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"));

Hierarchy

  • b2DebugDraw

Index

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

  • AppendFlags(flags: number): void
  • ClearFlags(flags: number): void
  • DrawPolygon(vertices: b2Vec2[], vertexCount: number, color: b2Color): 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

  • DrawSolidPolygon(vertices: b2Vec2[], vertexCount: number, color: b2Color): 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

  • GetAlpha(): number
  • GetDrawScale(): number
  • GetFillAlpha(): number
  • GetFlags(): number
  • GetLineThickness(): number
  • GetSprite(): CanvasRenderingContext2D
  • Get the HTML Canvas Element for drawing.

    note

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

    Returns CanvasRenderingContext2D

    The HTML Canvas Element used for debug drawing.

  • GetXFormScale(): number
  • SetAlpha(alpha: number): void
  • Set the alpha value used for lines.

    Parameters

    • alpha: number

      Alpha value for drawing lines.

    Returns void

  • SetDrawScale(drawScale: number): void
  • SetFillAlpha(alpha: number): void
  • Set the alpha value used for fills.

    Parameters

    • alpha: number

      Alpha value for drawing fills.

    Returns void

  • SetFlags(flags: number): void
  • SetLineThickness(lineThickness: number): void
  • Set the line thickness.

    Parameters

    • lineThickness: number

      The new line thickness.

    Returns void

  • SetSprite(canvas: CanvasRenderingContext2D): void
  • Set the HTML Canvas Element for drawing.

    note

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

    Parameters

    • canvas: CanvasRenderingContext2D

      HTML Canvas Element to draw debug information to.

    Returns void

  • SetXFormScale(xformScale: number): void
  • Set the scale used for drawing XForms.

    Parameters

    • xformScale: number

      The transform scale.

    Returns void

Generated using TypeDoc