Box2dPlugin

Box2D Global Object

  • Wraps Box2d world and provides global functions

Constructor

new Box2dPlugin(instance)

Create the global UI system object

Parameters:
NameTypeDescription
instanceObject

Members

bodyTypeDynamic

Properties
TypeDescription
number

Dynamic, positive mass, non-zero velocity determined by forces, moved by solver

bodyTypeKinematic

Properties
TypeDescription
number

Kinematic, zero mass, non-zero velocity set by user, moved by solver

bodyTypeStatic

Properties
TypeDescription
number

Static, zero mass, zero velocity, may be manually moved

positionIterations

Properties
TypeDescription
number

Position iterations per update

velocityIterations

Properties
TypeDescription
number

Velocity iterations per update

Methods

boxCast(pos, size)

box aabb cast and return the first object

Parameters:
NameTypeDescription
posVector2
sizeVector2

boxCastAll(pos, size)

box aabb cast and return all the objects

Parameters:
NameTypeDescription
posVector2
sizeVector2

castObjectType(o)

casts a box2d object to its correct type

Parameters:
NameTypeDescription
oObject

circleCast(pos, diameter)

circle cast and return the first object

Parameters:
NameTypeDescription
posVector2
diameternumber

circleCastAll(pos, diameter)

circle cast and return all the objects

Parameters:
NameTypeDescription
posVector2
diameternumber

drawFixture(fixture, pos, angle, coloropt, lineColoropt, lineWidthopt, contextopt)

draws a fixture

Parameters:
NameTypeAttributesDefaultDescription
fixtureObject
posVector2
anglenumber
colorColor<optional>
lineColorColor<optional>
lineWidthnumber<optional>
0.1
contextCanvasRenderingContext2D<optional>

isNull(o)

checks if a box2d object is null

Parameters:
NameTypeDescription
oObject

pointCast(pos, dynamicOnly)

point cast and return the first object

Parameters:
NameTypeDefaultDescription
posVector2
dynamicOnlybooleantrue

raycast(start, end)

raycast and return the first result

Parameters:
NameTypeDescription
startVector2
endVector2

raycastAll(start, end)

raycast and return a list of all the results

Parameters:
NameTypeDescription
startVector2
endVector2

step(framesopt)

Step the physics world simulation

Parameters:
NameTypeAttributesDefaultDescription
framesnumber<optional>
1

vec2From(v)

converts a box2d vec2 to a Vector2

Parameters:
NameTypeDescription
vObject

vec2FromPointer(v)

converts a box2d vec2 pointer to a Vector2

Parameters:
NameTypeDescription
vObject

vec2dTo(v)

converts a Vector2 to a box2 vec2

Parameters:
NameTypeDescription
vVector2