Debug class providing general utilities
Also serves as the base type for Debug draws.
Static methods
staticcreateGraphic(body:Body):Shape
Create a flash/openfl | nme Shape representing the given Body. |
---|
Parameters:
body | The body to create display Shape for. |
---|
Returns:
A flash/openfl | nme.display.Shape representing Body. |
---|
Throws:
# | If body is null. |
---|
Constructor
Variables
bgColour:Int
Background colour for debug draw display.
This value does not have much use for ShapeDebug, or for
a transparent BitmapDebug but will still be used in tinting
object colours to better fit an idealised background colour.
colour:Null<Int ‑> Int> = null
User defined colour picking.
When not null, this method will be called to decide which colour
to use for an object with argument being the id of that object.
The return value should be an RGB value.
cullingEnabled:Bool = false
When true, objects outside the debug draw screen will not be drawn.
The debug draw screen is defined as the rectangle (0,0) -> (width,height).
To 'move' the debug draw screen in your world, you should modify the transform
property.
This culling has a cost, so is not worth enabling if everything is always on
screen anyways.
read onlydisplay:DisplayObject
The flash/openfl | nme native display object representing debug draw. |
---|
When using debug drawer, you should add this to your display list.
drawBodyDetail:Bool = false
If true, then things like the body centre of mass, and bouncing box will be drawn.
This will only have an effect if drawBodies is true.
drawCollisionArbiters:Bool = false
If true, a representation of contact patches will be drawn.
Only active arbiters are drawn.
drawFluidArbiters:Bool = false
If true, a representation of centres of buoyancy and overlap will be drawn.
Only active arbiters are drawn.
drawSensorArbiters:Bool = false
If true, a representation of sensor interactions will be drawn.
Only active arbiters are drawn.
drawShapeAngleIndicators:Bool = false
If true, then indicators of the shapes rotation will be drawn.
This will only have an effect if drawBodies is true.
drawShapeDetail:Bool = false
If true, then things like shape centre of mass and bounding box will be drawn.
This will only have an effect if drawBodies is true.
transform:Mat23
Transformation to apply to all debug draw operations.
This transform can be used to 'move' the debug draw screen through your
world as well as rotating and zooming in etc.
This transform effects 'all' debug draw operations and optimisation is in
place to not perform any transformation if matrix is the identity matrix.
Methods
draw(object:Dynamic):Void
Draw a Nape object to debug draw.
Possible argument types are: Space, Compound, Body, Shape, Constraint
To draw a Shape it must be part of a Body.
Debug draw settings like 'drawBodies' are overriden by a direct call to draw
with a Body or Shape. Equally even if drawConstraints is false, should
you call draw with a Constraint object directly it will be drawn regardless.
Parameters:
object | The object to draw. |
---|
Throws:
# | If object is null or not of the expected Type. |
---|
drawAABB(aabb:AABB, colour:Int):Void
Draw AABB.
This AABB will be drawn with no thickness or fill.
Parameters:
aabb | The AABB to draw. |
---|---|
colour | The colour to draw AABB with in RGB. |
Throws:
# | If AABB is null. |
---|
drawCircle(position:Vec2, radius:Float, colour:Int):Void
Draw circle.
This circle will be drawn with no thickness or fill.
Parameters:
position | The position of circle centre. |
---|---|
radius | The radius of the circle. |
colour | The colour of circle in RGB. |
Throws:
# | If position is null or disposed of. |
---|---|
# | If radius is negative. |
# | If transform is not equiorthogonal. |
drawCurve(start:Vec2, control:Vec2, end:Vec2, colour:Int):Void
Draw quadratic bezier curve.
This curve will be drawn with no thickness.
Parameters:
start | The start point of curve. |
---|---|
control | The control point for curve. |
end | The end point of curve. |
colour | The colour of curve in RGB. |
Throws:
# | If any Vec2 argument is null or disposed of. |
---|
drawFilledCircle(position:Vec2, radius:Float, colour:Int):Void
Draw filled circle.
This circle will be drawn with no edges, only a solid fill.
Parameters:
position | The position of centre of circle. |
---|---|
radius | The radius of circle. |
colour | The colour to draw circle with in RGB. |
Throws:
# | If position is null or disposed of. |
---|---|
# | If radius is negative. |
# | If transform is not equiorthogonal. |
drawFilledPolygon(polygon:Dynamic, colour:Int):Void
Draw filled polygon.
This polygon will be drawn no edges, only a solid fill.
The polygon argument is typed Dynamic and may be one of:
Array<Vec2>, flash.Vector<Vec2>, Vec2List, GeomPoly
Parameters:
polygon | The polygon to draw. |
---|---|
colour | The colour to draw polygon with in RGB. |
Throws:
# | If polygon is null, or not of expected type. |
---|---|
# | If polygon contains disposed Vec2. |
drawFilledTriangle(p0:Vec2, p1:Vec2, p2:Vec2, colour:Int):Void
Draw filled triangle.
This triangle will be drawn with no edges, only a solid fill.
Parameters:
p0 | The first point in triangle. |
---|---|
p1 | The second point in triangle. |
p2 | The third point in triangle. |
colour | The colour to draw triangle with in RGB. |
Throws:
# | If any point argument is null or disposed of. |
---|
drawLine(start:Vec2, end:Vec2, colour:Int):Void
Draw a line segment.
This line will be drawn with no thickness.
Parameters:
start | The start point of line segment. |
---|---|
end | The end point of line segment. |
colour | The colour of line in RGB. |
Throws:
# | If either start or end are null or disposed of. |
---|
drawPolygon(polygon:Dynamic, colour:Int):Void
Draw polygon.
This polygon will be drawn with no thickness or fill.
The polygon argument is typed Dynamic and may be one of:
Array<Vec2>, flash.Vector<Vec2>, Vec2List, GeomPoly
Parameters:
polygon | The polygon to draw. |
---|---|
colour | The colour to draw polygon with in RGB. |
Throws:
# | If polygon is null, or not of expected type. |
---|---|
# | If polygon contains disposed Vec2. |
drawSpring(start:Vec2, end:Vec2, colour:Int, coils:Int = 3, radius:Float = 3.0):Void
Draw linear spring.
This spring will be drawn with no thickness.
Parameters:
start | The start point of spring. |
---|---|
end | The end point of spring. |
colour | The colour of spring in RGB. |
coils | The number of coils in spring. (default 3) |
radius | The radius of spring. (default 3.0) |
Throws:
# | If start or end are either null or disposed of. |
---|---|
# | If number of coils is negative. |