Packagecom.boristhebrave.Box2DWith
Classpublic class b2Graphics

A re-implementation of debug drawing without the hassles of Box2D's API. By drawing into Sprites which you persist through frames, the methods here are appropriate for production release.



Public Properties
 PropertyDefined by
  awakeColor : uint = 0xE6E6E6
The color to use for awake dynamic bodies.
b2Graphics
  fillAlpha : Number = 0.5
The alpha to use for filling in bodies.
b2Graphics
  graphics : Graphics
The wrapped Graphics to draw to.
b2Graphics
  jointColor : uint = 0x80CDCD
The color to use for drawing joints.
b2Graphics
  lineThickness : Number = 1
The line thickness to use for drawing, in pixels.
b2Graphics
  physScale : Number
The scale between pixels and Box2D units, in pixels/unit.
b2Graphics
  sleepColor : uint = 0x8080E6
The color to use for sleeping dynamic bodies.
b2Graphics
  staticColor : uint = 0x80E680
The color to use for static bodies.
b2Graphics
  xformScale : Number = 3
The size to draw xforms at, in units.
b2Graphics
Public Methods
 MethodDefined by
  
b2Graphics(graphics:Graphics, physScale:Number)
Creates a wrapper for Graphics, with it's own set of drawing properties.
b2Graphics
  
drawBody(body:b2Body):void
Draws a body, including styling.
b2Graphics
  
drawBodyLocal(body:b2Body):void
Draws a body in local co-ordinates, including styling.
b2Graphics
  
drawBodyOutline(body:b2Body):void
Draws the given body, without setting any style properties.
b2Graphics
  
drawBodyOutlineLocal(body:b2Body):void
Draws the given body in local cordinates, without setting any style properties.
b2Graphics
  
drawJoint(joint:b2Joint):void
Draws a joint, including styling.
b2Graphics
  
drawJointOutline(joint:b2Joint):void
Draws the given joint, without setting any style properties.
b2Graphics
  
drawSegment(p1:b2Vec2, p2:b2Vec2):void
Draws an unstyled line.
b2Graphics
  
drawShapeOutline(shape:b2Shape):void
Draws the given shape in world co-ordinates, without setting any style properties.
b2Graphics
  
drawShapeOutlineLocal(shape:b2Shape):void
Draws the given shape in local co-ordinates, without setting any style properties.
b2Graphics
  
drawWorld(world:b2World):void
Draws a world, including styling.
b2Graphics
Property detail
awakeColorproperty
public var awakeColor:uint = 0xE6E6E6

The color to use for awake dynamic bodies.

fillAlphaproperty 
public var fillAlpha:Number = 0.5

The alpha to use for filling in bodies.

graphicsproperty 
public var graphics:Graphics

The wrapped Graphics to draw to.

jointColorproperty 
public var jointColor:uint = 0x80CDCD

The color to use for drawing joints.

lineThicknessproperty 
public var lineThickness:Number = 1

The line thickness to use for drawing, in pixels.

physScaleproperty 
public var physScale:Number

The scale between pixels and Box2D units, in pixels/unit.

sleepColorproperty 
public var sleepColor:uint = 0x8080E6

The color to use for sleeping dynamic bodies.

staticColorproperty 
public var staticColor:uint = 0x80E680

The color to use for static bodies.

xformScaleproperty 
public var xformScale:Number = 3

The size to draw xforms at, in units.

Constructor detail
b2Graphics()constructor
public function b2Graphics(graphics:Graphics, physScale:Number)

Creates a wrapper for Graphics, with it's own set of drawing properties.

Parameters
graphics:Graphics — The Graphics object to wrap.
 
physScale:Number — The scaling to use, in pixels/unit.
Method detail
drawBody()method
public function drawBody(body:b2Body):void

Draws a body, including styling.

Parameters
body:b2Body
drawBodyLocal()method 
public function drawBodyLocal(body:b2Body):void

Draws a body in local co-ordinates, including styling.

Parameters
body:b2Body
drawBodyOutline()method 
public function drawBodyOutline(body:b2Body):void

Draws the given body, without setting any style properties. Use this instead of drawBody if you want a more customized looking shape.

Parameters
body:b2Body
drawBodyOutlineLocal()method 
public function drawBodyOutlineLocal(body:b2Body):void

Draws the given body in local cordinates, without setting any style properties. Use this instead of drawBodyLocal if you want a more customized looking shape.

Parameters
body:b2Body
drawJoint()method 
public function drawJoint(joint:b2Joint):void

Draws a joint, including styling.

Parameters
joint:b2Joint
drawJointOutline()method 
public function drawJointOutline(joint:b2Joint):void

Draws the given joint, without setting any style properties. Use this instead of drawJoint if you want a more customized looking shape.

Parameters
joint:b2Joint
drawSegment()method 
public function drawSegment(p1:b2Vec2, p2:b2Vec2):void

Draws an unstyled line.

Parameters
p1:b2Vec2
 
p2:b2Vec2
drawShapeOutline()method 
public function drawShapeOutline(shape:b2Shape):void

Draws the given shape in world co-ordinates, without setting any style properties. Use this instead of drawShape if you want a more customized looking shape.

Parameters
shape:b2Shape
drawShapeOutlineLocal()method 
public function drawShapeOutlineLocal(shape:b2Shape):void

Draws the given shape in local co-ordinates, without setting any style properties. Use this instead of drawShapeLocal if you want a more customized looking shape.

Parameters
shape:b2Shape
drawWorld()method 
public function drawWorld(world:b2World):void

Draws a world, including styling. Note that it is more efficient to draw bodies into separate DisplayObjects once, and then move them around, than to call drawWorld once per frame.

Parameters
world:b2World