Constructors

Fields Summary

PhysicsObject.active

Whether the physics object is active. Inactive objects are not simulated and cannot be collided with.
PhysicsObject.allowSleeping

Whether this object should be allowed to sleep. Objects are set to sleep when resting on other objects, to speed up the simulation.
PhysicsObject.angularDamping

The amount of damping (reduction in velocity) that is caused by angular motion. Usually between 0 and 1 (0 by default).
PhysicsObject.bodyType

The type of physics body. This is 'static' by default, indicating an immovable object. It can also be 'dynamic' or 'kinematic'
PhysicsObject.bullet

Whether the object is a bullet (a fast-moving object), which implies that it needs continuous collision detection to avoid going through objects
PhysicsObject.fixedRotation

Whether this object should only translate and never rotate.
PhysicsObject.gravityScale

A number to multiply the effect of gravity on this body. Setting this to 0 means that the object is not affected by gravity.
PhysicsObject.linearDamping

The amount of damping (reduction in velocity) that is caused by linear motion. Usually between 0 and 1 (0 by default).

Functions Summary

PhysicsObject.addFixture (fData)

Add a fixture to the physics body. A fixture is a convex shape with physics properties, and each physics body can have any number of fixtures.
PhysicsObject.addMouseJoint (offset)

Add a mouse joint. A mouse joint is a target point that the object will try to follow when possible.
PhysicsObject.applyForce (force, power, offset)

applyForce
PhysicsObject.applyImpulse (impulse, power, offset)

applyImpulse
PhysicsObject.applyTorque (torque)

applyTorque
PhysicsObject.draw_ (color, originalDraw)

Get a debug draw function that shows the physics object using vector graphics. It currently only works for circle shapes.
PhysicsObject.getFixtureList ()

Get a list of fixtures attached to this object
PhysicsObject.getJointList ()

Get a list of joints attached to this object
PhysicsObject.isAwake ()

Check whether the physics object is awake or not. Objects can be not awake when they're resting on top of other objects, to improve the performance of the simulation
PhysicsObject.removeFixture (fixture)

removeFixture Remove a fixture
PhysicsObject.removeMouseJoint (joint)

Remove a mouse joint from this object
PhysicsObject.setAwake (value)

Set a physics object as awake or not. Objects can be not awake when they're resting on top of other objects, to improve the performance of the simulation
PhysicsObject.updateMouseJoint (joint, pos)

Update the position of the target point for a mouse joint

Fields Details

PhysicsObject.active

Whether the physics object is active. Inactive objects are not simulated and cannot be collided with.
^
PhysicsObject.allowSleeping

Whether this object should be allowed to sleep. Objects are set to sleep when resting on other objects, to speed up the simulation.
^
PhysicsObject.angularDamping

The amount of damping (reduction in velocity) that is caused by angular motion. Usually between 0 and 1 (0 by default).
^
PhysicsObject.bodyType

The type of physics body. This is 'static' by default, indicating an immovable object. It can also be 'dynamic' or 'kinematic'
^
PhysicsObject.bullet

Whether the object is a bullet (a fast-moving object), which implies that it needs continuous collision detection to avoid going through objects
^
PhysicsObject.fixedRotation

Whether this object should only translate and never rotate.
^
PhysicsObject.gravityScale

A number to multiply the effect of gravity on this body. Setting this to 0 means that the object is not affected by gravity.
^
PhysicsObject.linearDamping

The amount of damping (reduction in velocity) that is caused by linear motion. Usually between 0 and 1 (0 by default).
^

Function Details

PhysicsObject.addFixture (fData)

Add a fixture to the physics body. A fixture is a convex shape with physics properties, and each physics body can have any number of fixtures.

object fData : The fixture data for the fixture to add to this body. The data structure is as follows - please refer to the box2d documentation for a full explanation of each parameter:

density: number
filter: {categoryBits: number, groupIndex: number, maskBits: number}
friction: number
isSensor: number
restitution: number
offset: {x: number, y: number, ang: number}
shapeType: string (valid values are 'edge', 'chain', 'loopChain', 'box', 'circle', 'polygon')
vertices: [{x: number, y: number}]


Returns object : The fixture object. This can later be used to remove a fixture through removeFixture().

^
PhysicsObject.addMouseJoint (offset)

Add a mouse joint. A mouse joint is a target point that the object will try to follow when possible.

{x: number, y: number} offset (optional): The point in object-space that will try to track the target point.


Returns : A mouse joint object

^
PhysicsObject.applyForce (force, power, offset)

applyForce
Apply a force to a box2d body
As this uses a normalized vector, do not convert the force using wadeToBox.
However, since the y axis are reversed in wade vs box2d, multiply the force.y by -1

object force : a vector with x and y parameters designating the direction of the force


number power : a number to multiply the bodies mass by to generate the total power


object offset : a vector with x and y parameters designating the offset point at which to apply the force

^
PhysicsObject.applyImpulse (impulse, power, offset)

applyImpulse
Apply an impulse to a box2d body
As this uses a normalized vector, do not convert the impulse using wadeToBox.
However, since the y axis are reversed in wade vs box2d, multiply the impulse.y by -1

object impulse : a vector with x and y parameters designating the direction of the impulse


number power : a number to multiply the bodies mass by to generate the total power


object offset : a vector with x and y parameters designating the offset point at which to apply the impulse

^
PhysicsObject.applyTorque (torque)

applyTorque
Apply a torque to the body in newton-meters
Affects the angular velocity but not the linear velocity

{number) : torque the amount of torque to apply in newton*meters

^
PhysicsObject.draw_ (color, originalDraw)

Get a debug draw function that shows the physics object using vector graphics. It currently only works for circle shapes.

string color (optional): The color to use to draw the silhouette of the physics object. Default is 'green'.


function originalDraw (optional): A draw function to call after drawing the silhouette of the physics object.


Returns function : A draw function to use with Sprite.setDrawFunction()

^
PhysicsObject.getFixtureList ()

Get a list of fixtures attached to this object

Returns Array : An array of fixtures attached to this physics body

^
PhysicsObject.getJointList ()

Get a list of joints attached to this object

Returns Array : an array of joint objects attached to this body

^
PhysicsObject.isAwake ()

Check whether the physics object is awake or not. Objects can be not awake when they're resting on top of other objects, to improve the performance of the simulation

Returns boolean : Whether the physics object is awake

^
PhysicsObject.removeFixture (fixture)

removeFixture Remove a fixture

object fixture : The fixture object to remove from this physics body, as previously returned by a call to createFixture

^
PhysicsObject.removeMouseJoint (joint)

Remove a mouse joint from this object

object joint (optional): The joint object to remove. If omitted, the first mouse joint will be removed.

^
PhysicsObject.setAwake (value)

Set a physics object as awake or not. Objects can be not awake when they're resting on top of other objects, to improve the performance of the simulation

boolean value : Whether the physics object should be awake

^
PhysicsObject.updateMouseJoint (joint, pos)

Update the position of the target point for a mouse joint

object joint (optional): The joint object to update, as previously returned by a call to addMouseJoint(). It can be omitted, in which case the first mouse joint will be used.


{x: number, y: number} pos : The new position of the target point

^