PhysicsScene
This class is made up to the native b2World class. It manages basic world properties and functions.
Properties
-
autoClearForces : Boolean
Flag to control automatic clearing of forces after each time step. By default it is set to true.
-
clearForces
Manually clear the force buffer on all bodies. By default, forces are cleared automatically after each call to Step.
-
native : b2World
Instance of native b2World.
-
scale : Float
Value represent scale of box2d world against screen resolution.
-
world : b2World
Physics world, b2World native instance.
Methods
-
addCircleBody(image, bodyTypeSym, density, friction, bounce, radius) : PhysicsBody
Add circle Body.
-
addPolygonBody(image, bodyTypeSym, density, friction, bounce, width, height) : PhysicsBody
Add polygon Body.
-
create(gx, gy,options = {}) : PhysicsScene
Factory to create object.
-
createDistanceJoint( bodyA, bodyB, anchorAx, anchorAy, anchorBx, anchorBy, jointDef, collideConnected) : b2DistanceJoint
A mouse joint is used to make a point on a body track a specified world point.
-
createFrictionJoint(bodyA, bodyB, x, y, jointDef, collideConnected) : b2FrictionJoint
The friction joint is used for top-down friction. The joint provides 2D translational friction and angular friction.
-
createGearJoint(bodyA, bodyB, joint1, joint2, ratio, collideConnected) : b2GearJoint
If you want to create a sophisticated mechanical contraption you might want to use gears. Gear joint connects two other types of joints and move them with set ratio.
-
createLineJoint(bodyA, bodyB, anchorX, anchorY , axisX, axisY, jointDef , collideConnected) : b2LineJoint
This joint provides two degrees of freedom: translation along an axis fixed in body1 and rotation in the plane.
-
createMouseJoint(bodyA, bodyB, jointDef, collideConnected) : b2MouseJoint
A mouse joint is used to make a point on a body track a specified world point.
-
createPrismaticJoint(bodyA, bodyB, anchorX, anchorY , axisX, axisY, referenceAngle, jointDef, collideConnected) : b2PrismaticJoint
A prismatic joint allows for relative translation of two bodies along a specified axis.
-
createPulleyJoint( bodyA, bodyB, groundAnchorAX, groundAnchorAY, groundAnchorBX, groundAnchorBY, anchorAX, anchorAY, anchorBX, anchorBY, ratio , collideConnected ) : b2PulleyJoint
The pulley joint is connected to two bodies and two fixed ground points.
-
createRevoluteJoint(bodyA, bodyB, x, y, jointDef, collideConnected) : b2RevoluteJoint
A mouse joint is used to make a point on a body track a specified world point.
-
createWeldJoint( bodyA, bodyB, anchorX, anchorY, collideConnected ) : b2WeldJoint
A weld joint essentially glues two bodies together. It may distort somewhat because the island constraint solver is approximate.
-
destroyBody(body)
Destroy body and remove from bodies array.
-
destroyJoint(joint) : b2WeldJoint
Destroy Joint.
-
doDebugDraw(canvas)
Draw physics scene, in debug mode
-
draw(canvas)
Draw physics scene
-
getBody(body) : PhysicsBody
Get body from bodies array
-
getBodyCount() : Integer
Get the number of bodies.
-
getContactCount() : Integer
Get the number of contacts (each may have 0 or more contact points).
-
getGravity() : Multivalue
Get the global gravity.
-
getJointCount() : Integer
Get the number of joints.
-
getProxyCount() : Integer
Get the number of broad-phase proxies.
-
setContinuousPhysics(flag)
Enable/disable continuous physics. For testing purposes.
-
setGravity(gx, gy) : Multivalue
Set the global gravity
-
setWarmStarting(flag)
Enable/disable warm starting. For testing purposes.
-
step(timeStep = 1.0/40.0, velocityIterations = 4, positionIterations = 8)
Take a time step. This performs collision detection, integration, and constraint solution.
Events
-
onBeginContact : Function
Event to be called, when two bodies collide.
-
onEndContact : Function
Event to be called, when contact ends.
|
|
|
 |
PhysicsContact
|
|
|
 |
PhysicsSprite
|
|
 |
Game
|
|
 |
Canvas
|
|
 |
Bitmap
|
|
 |
Paint
|
|