Constructors

- Wade.physics

Constructor Summary

WADE Physics - This is the physics plugin module for WADE by Clockwork Chilli.

Functions Summary

Get the current gravity vector
Get the current number of iterations for the physics position solver.
Get the current time step value for the physics simulation
Get the current number of iterations for the physics velocity solver.
init
(options)
Initialize the physics plugin.
Check whether the physics engine has been initialized.
Check whether the physics simulation is currently running
Check whether we are in the middle of a physics step
setGravity
(gravity)
Set a new value for gravity (by default gravity is {x:0, y:9.81}
setPositionIterations
(positionIterations)
Set the number of iterations for the physics position solver.
setTimeStep
(timeStep)
Set the time step value for the physics simulation.
setVelocityIterations
(velocityIterations)
Get the current number of iterations ofr the physics velocity solver.
Start the physics simulation.
step()
Step the box2d physics world forward.
Stop (pause) the physics simulation.

Constructor Details

()
WADE Physics - This is the physics plugin module for WADE by Clockwork Chilli. It is based on the popular open-source Box2D physics engine. To enable it, simply include the javascript file in your project (after the main WADE module), and include box2d.min.js This object exposes a minimal interface that affects the global physics simulation. Use the PhysicsObject behavior to control several per-object parameters.

Function Details

()
Get the current gravity vector

Returns:


{{x: number|y: number}}
The current gravity vector
()
Get the current number of iterations for the physics position solver.

Returns:


{number}
The current number of iterations for the physics position solver.
()
Get the current time step value for the physics simulation

Returns:


{number}
The current time step value for the physics simulation
()
Get the current number of iterations for the physics velocity solver.

Returns:


{number}
The current number of iterations for the physics velocity solver.

(options)
Initialize the physics plugin. This function must be called once for the physics simulation to work. This normally happens automatically the fist time you try to use the physics engine and you don't need to call it directly from your code.

Parameters:


{object}optionsOptional
An object with some of the following fields, which are all optional:
  • gravity: an object with x and y fields, describing the gravity in meters/seconds squared. By default, this is {x:0, y:9.81}.
  • timeStep: the time interval used in the box2d Step function. Default is wade.c_timeStep
  • positionIterations: a number describing how many positions iterations to use in the box2d solver. Default is 4
  • velocityIterations: a number describing how many velocity iterations to use in the box2d solver. Default is 2
()
Check whether the physics engine has been initialized.

Returns:


{boolean}
Whether the physics engine has been initialized.
()
Check whether the physics simulation is currently running

Returns:


{boolean}
Whether the physics simulation is currently running
()
Check whether we are in the middle of a physics step

Returns:


{boolean}

(gravity)
Set a new value for gravity (by default gravity is {x:0, y:9.81}

Parameters:


{{x: number|y: number}}gravity
The new gravity vector

(positionIterations)
Set the number of iterations for the physics position solver. By default this is 4.

Parameters:


{number}positionIterations
The number of iterations for the physics position solver. Use a larger number for greater accuracy (but it will be slower)

(timeStep)
Set the time step value for the physics simulation. By default this matches WADE's simulation time step (1/60 seconds)

Parameters:


{number}timeStep
The length (in seconds) of the time step for the physics simulation

(velocityIterations)
Get the current number of iterations ofr the physics velocity solver. By default this is 2.

Parameters:


{number}velocityIterations
The number of iterations for the physics velocity solver. Use a larger number for greater accuracy (but it will be slower)
()
Start the physics simulation. Note that the simulation is started automatically when wade.physics.init() is called, so it only makes sense to call this function after a call to stopSimulation().

()
Step the box2d physics world forward. This normally happens automatically.

()
Stop (pause) the physics simulation.