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 Dynamics.b2DebugDraw(); debugDraw.SetSprite(document.GetElementsByTagName("canvas")[0].getContext("2d"));

Hierarchy

  • b2DebugDraw

Index

Constructors

constructor

  • Constructor.

    Returns b2DebugDraw

Properties

Static e_aabbBit

e_aabbBit: number

Draw axis aligned bounding boxes.

Static e_centerOfMassBit

e_centerOfMassBit: number

Draw center of mass frame.

Static e_controllerBit

e_controllerBit: number

Draw controllers.

Static e_jointBit

e_jointBit: number

Draw joint connections.

Static e_pairBit

e_pairBit: number

Draw broad-phase pairs.

Static e_shapeBit

e_shapeBit: number

Draw shapes.

Methods

AppendFlags

  • AppendFlags(flags: number): void
  • Append flags to the current flags.

    Parameters

    • flags: number

      Flags to add.

    Returns void

ClearFlags

  • ClearFlags(flags: number): void
  • Clear flags from the current flags.

    Parameters

    • flags: number

      flags to clear.

    Returns void

DrawCircle

  • DrawCircle(center: b2Vec2, radius: number, color: b2Color): void
  • Draw a circle.

    Parameters

    • center: b2Vec2

      Circle center point.

    • radius: number

      Circle radius.

    • color: b2Color

      Circle draw color.

    Returns void

DrawPolygon

  • 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

DrawSegment

  • Draw a line segment.

    Parameters

    Returns void

DrawSolidCircle

  • Draw a solid circle.

    Parameters

    • center: b2Vec2

      Circle center point.

    • radius: number

      Circle radius.

    • axis: b2Vec2

      Circle axis.

    • color: b2Color

      Circle color.

    Returns void

DrawSolidPolygon

  • 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

DrawTransform

  • Draw a transform. Choose your own length scale.

    Parameters

    Returns void

GetAlpha

  • GetAlpha(): number
  • Get the alpha value used for lines.

    Returns number

    Alpha value used for drawing lines.

GetDrawScale

  • GetDrawScale(): number
  • Get the draw scale.

    Returns number

    Draw scale ratio.

GetFillAlpha

  • GetFillAlpha(): number
  • Get the alpha value used for fills.

    Returns number

    Alpha value used for drawing fills.

GetFlags

  • GetFlags(): number
  • Get the drawing flags.

    Returns number

    Drawing flags.

GetLineThickness

  • GetLineThickness(): number
  • Get the line thickness.

    Returns number

    Line thickness.

GetSprite

  • 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

  • GetXFormScale(): number
  • Get the scale used for drawing XForms.

    Returns number

    Scale for drawing transforms.

SetAlpha

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

    Parameters

    • alpha: number

      Alpha value for drawing lines.

    Returns void

SetDrawScale

  • SetDrawScale(drawScale: number): void
  • Set the draw scale.

    Parameters

    • drawScale: number

      Draw scale ratio.

    Returns void

SetFillAlpha

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

    Parameters

    • alpha: number

      Alpha value for drawing fills.

    Returns void

SetFlags

  • SetFlags(flags: number): void
  • Set the drawing flags.

    Parameters

    • flags: number

      Sets the drawing flags.

    Returns void

SetLineThickness

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

    Parameters

    • lineThickness: number

      The new line thickness.

    Returns void

SetSprite

  • 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

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

    Parameters

    • xformScale: number

      The transform scale.

    Returns void

Generated using TypeDoc