Developer   API   b2World

API

b2World

The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.

List of all members

  • b2World - The world class manages all physics entities, dynamic simulation, and asynchronous queries. The world also contains efficient memory management facilities.
  • this([xGravity[,yGravity[,doSleep[,enableCollisions]]]]) - Construct a world object.
  • step(timeStep,velocityIterations,velocityIterations ) - Take a time step. This performs collision detection, integration, and constraint solution.
  • clearForces() - Manually clear the force buffer on all bodies. By default, forces are cleared automatically after each call to Step.
  • doDraw(canvas) - Call this to redraw all objects in curent world.
  • doDebugDraw(canvas) - Call this to draw shapes and other debug draw data.
  • createBody(shape, [bodyTypeSym, density, friction, bounce, x, y]) - Create new box2d body and place it to the x, y.
  • createDistanceJoint(bodyA, bodyB, anchorXA, anchorYA, anchorXB, anchorYB, scriptDef[, collideConnected]) - Create distance joint between two objects. Distance joints says that the distance between two points on two bodies must be constant.
  • createRevoluteJoint( bodyA, bodyB, anchorX, anchorY, scriptDef [,collideConnected]) - A revolute joint forces two bodies to share a common anchor point, often called a hinge point. The revolute joint has a single degree of freedom: the relative rotation of the two bodies. This is called the joint angle.
  • createFrictionJoint(bodyA, bodyB, anchorX, anchorY, scriptDef[, collideConnected]) - The friction joint is used for top-down friction. The joint provides 2D translational friction and angular friction.
  • createGearJoint(bodyA, bodyB, jojnt1, jojnt2, ratio [, collideConnected]) - 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.
  • createPrismaticJoint( bodyA, bodyB, anchorX, anchorY, axisX, axisY, referenceAngle, scriptDef [, collideConnected]) - A prismatic joint allows for relative translation of two bodies along a specified axis.
  • createLineJoint(bodyA, bodyB, anchorX, anchorY, axisX, axisY, scriptDef[, collideConnected]) - This joint provides two degrees of freedom: translation along an axis fixed in body1 and rotation in the plane.
  • createMouseJoint(bodyA, bodyB, scriptDef[, collideConnected]) - A mouse joint is used to make a point on a body track a specified world point.
  • createPulleyJoint(bodyA, bodyB, groundAnchorAX, groundAnchorAY, groundAnchorBX, groundAnchorBY, anchorAX, anchorAY, anchorBX, anchorBY, ratio[, collideConnected]) - The pulley joint is connected to two bodies and two fixed ground points.
  • createWeldJoint(bodyA, bodyB, anchorX, anchorY[, collideConnected]) - A weld joint essentially glues two bodies together.A weld joint may distort somewhat because the island constraint solver is approximate.
  • destroyJoint(joint) - Destroy a joint.
  • createBody(body) - Destroy existing physics body.
  • setWarmStarting(flag) - Enable/disable warm starting. For testing.
  • setContinuousPhysics(flag) - Enable/disable continuous physics. For testing.
  • getProxyCount() - Get the number of broad-phase proxies.
  • getBodyCount() - Get the number of bodies.
  • getJointCount() - Get the number of joints.
  • getContactCount() - Get the number of contacts (each may have 0 or more contact points).
  • setGravity(gx, gy) - Set world’s gravity (separately for x and y axis).
  • getGravity() - Get the global gravity.
  • autoClearForces - Flag to control automatic clearing of forces after each time step. By default it is set to true.
  • scale - Value represent scale of box2d world against screen resolution.
  • onBeginContact(sender, contact) - This function is called, when two bodies collide.
  • onEndContact(sender, contact) - This function is called, when contact ends.