Constructors

- PhysicsObject

Constructor Summary

PhysicsObject is a behavior to be used with WADE, and is part of the wade.physics plug-in.

Fields Summary

active
active
Whether the physics object is active.
allowSleeping
allowSleeping
Whether this object should be allowed to sleep.
angularDamping
angularDamping
The amount of damping (reduction in velocity) that is caused by angular motion.
bodyType
bodyType
The type of physics body.
bullet
bullet
Whether the object is a bullet (a fast-moving object), which implies that it needs continuous collision detection to avoid going throug object
fixedRotation
fixedRotation
Whether this object should only translate and never rotate.
gravityScale
gravityScale
A number to multiply the effect of gravity on this body.
linearDamping
linearDamping
The amount of damping (reduction in velocity) that is caused by linear motion.

Functions Summary

addFixture
(fData)
Add a fixture to the physics body.
addMouseJoint
(offset)
Add a mouse joint.
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.
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.
applyTorque
(torque)
applyTorque Apply a torque to the body in newton-meters Affects the angular velocity but not the linear velocity
draw_
(color,
originalDraw)
Get a debug draw function that shows the physics object using vector graphics.
Get a list of fixtures attached to this object
Get a list of joints attached to this object
Check whether the physics object is awake or not.
removeFixture
(fixture)
removeFixture Remove a fixture
Remove a mouse joint from this object
setAwake
(value)
Set a physics object as awake or not.
updateMouseJoint
(joint,
pos)
Update the position of the target point for a mouse joint

Constructor Details

()
PhysicsObject is a behavior to be used with WADE, and is part of the wade.physics plug-in.
It gives you access to many physical properties for WADE objects.
Example usage: var mySceneObject = new SceneObject(mySprite, PhysicsObject);
mySceneObject.getBehavior().linearDamping = 0.3;

Fields Details


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


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


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


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


Whether the object is a bullet (a fast-moving object), which implies that it needs continuous collision detection to avoid going throug object


Whether this object should only translate and never rotate.


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


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

Function Details


(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.

Parameters:


fData

Returns:


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

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

Parameters:


{{x: number|y: number}}offsetOptional
The point in object-space that will try to track the target point.

Returns:


undefined

(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

Parameters:


force
power
offset

(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

Parameters:


impulse
power
offset

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

Parameters:


torque

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

Parameters:


{string}colorOptional
The color to use to draw the silhouette of the physics object. Default is 'green'.
{function}originalDrawOptional
A draw function to call after drawing the silhouette of the physics object.

Returns:


{function}
A draw function to use with Sprite.setDrawFunction()
()
Get a list of fixtures attached to this object

Returns:


{Array}
An array of fixtures attached to this physics body
()
Get a list of joints attached to this object

Returns:


{Array}
an array of joint objects attached to this body
()
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

(fixture)
removeFixture Remove a fixture

Parameters:


fixture

(joint)
Remove a mouse joint from this object

Parameters:


{object}jointOptional
The joint object to remove. If omitted, the first mouse joint will be removed.

(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

Parameters:


value

(joint,
pos)
Update the position of the target point for a mouse joint

Parameters:


{object}jointOptional
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