Developer   API   b2Body

API

b2Body

This class manages different types of physical bodies with many different properties and behavior.

List of all members

  • b2Body - This class manages different types of physical bodies with many different properties and behavior.
  • setTransform(x, y, angle) - Set the position of the body's origin and rotation. This breaks any contacts and wakes the other bodies. Manipulating a body's transform may cause non-physical behavior.
  • getPosition() - Get the body's origin position.
  • setPosition(x, y) - Place body to x, y.
  • getAngle() - Get the body's angle in radians.
  • setAngle(angle) - Set the body's rotation angle in radians.
  • getWorldCenter() - Get the world position of the center of mass.
  • getLocalCenter() - Get the local position of the center of mass.
  • setLinearVelocity(x, y) - Set linear velocity of the center of mass.
  • getLinearVelocity() - Get linear velocity of the center of mass.
  • applyForce(xForce, yForce, xPoint, yPoint) - Apply a force at a world point. If the force is not applied at the center of mass, it will generate a torque and affect the angular velocity. This wakes up sleeping body.
  • applyTorque(torque) - Apply a torque. This affects the angular velocity without affecting the linear velocity of the center of mass. This wakes up the body.
  • applyLinearImpulse(xForce,yForce,xPoint,yPoint) - Apply an impulse at a point. This immediately modifies the velocity. It also modifies the angular velocity if the point of application is not at the center of mass. If the body is sleeping, this wakes up it.
  • applyAngularImpulse(impulse) - Apply an angular impulse.
  • getWorldPoint(x, y) - Get the world coordinates of a point given by the local coordinates.
  • getWorldVector(x, y) - Convert local vector's x and y component to world vector's components.
  • getLocalPoint(x, y) - Gets a local point relative to the body's origin given a world point.
  • getLocalVector(x, y) - Gets a local vector's x and y from given world vector's x and y coordinates.
  • getMass() - Get the total mass of the body.
  • getInertia() - Get the rotational inertia of the body about the local origin.
  • getLinearVelocityFromWorldPoint(x, y) - Get the world linear velocity of a world point attached to this body.
  • getLinearVelocityFromLocalPoint(x, y) - Get the world velocity of a local point.
  • setLinearDamping(damping) - Set linear damping of the body.
  • getLinearDamping() - Get linear damping of the body.
  • setAngularDamping(damping) - Set angular damping of the body.
  • getAngularDamping() - Get angular damping of the body.
  • bodyType - The type of this body. This may alter the mass and velocity.
  • bullet - Is this body treated like a bullet for continuous collision detection?
  • sleepingAllowed - You can disable sleeping on this body. If you disable sleeping onChar actualy sleeping body, the body will be woken.
  • awake - Set to true to put body to sleep, false to wake it. A sleeping body has very low CPU cost.
  • active - Set the active state of the body.
  • fixedRotation - Enable / disable rotation of the body.
  • onEndContact(sender, canvas) - This function is called, when body needs to be redrawn.