Moai SDK  2.0
MOAIBox2DWorld Class Reference
+ Inheritance diagram for MOAIBox2DWorld:

Function List

addBody
 
addDistanceJoint
 
addFrictionJoint
 
addGearJoint
 
addMotorJoint
 
addMouseJoint
 
addPrismaticJoint
 
addPulleyJoint
 
addRevoluteJoint
 
addRevoluteJointLocal
 
addRopeJoint
 
addWeldJoint
 
addWheelJoint
 
getAngularSleepTolerance
 
getAutoClearForces
 
getGravity
 
getLinearSleepTolerance
 
getPerformance
 
getRayCast
 
getTimeToSleep
 
setAngularSleepTolerance
 
setAutoClearForces
 
setDebugDrawEnabled
 
setDebugDrawFlags
 
setGravity
 
setIterations
 
setLinearSleepTolerance
 
setTimeToSleep
 
setUnitsToMeters
 
- Function List inherited from MOAIAction
addChild
 
attach
 
clear
 
defer
 
detach
 
getChildren
 
hasChildren
 
isActive
 
isBusy
 
isDone
 
isPaused
 
pause
 
setAutoStop
 
start
 
stop
 
throttle
 
update
 
- Function List inherited from MOAIInstanceEventSource
getListener
 
setListener
 

Detailed Description

Constants
MOAIBox2DWorld.DEBUG_DRAW_SHAPES
MOAIBox2DWorld.DEBUG_DRAW_JOINTS
MOAIBox2DWorld.DEBUG_DRAW_BOUNDS
MOAIBox2DWorld.DEBUG_DRAW_PAIRS
MOAIBox2DWorld.DEBUG_DRAW_CENTERS
MOAIBox2DWorld.DEBUG_DRAW_DEFAULT

Function Documentation

addBody

Create and add a body to the world.


function addBody ( MOAIBox2DWorld self, number type [, number x, number y ] )

Parameters
MOAIBox2DWorldself
numbertype One of MOAIBox2DBody.DYNAMIC, MOAIBox2DBody.KINEMATIC, MOAIBox2DBody.STATIC
numberx Optional. in units, in world coordinates, converted to meters
numbery Optional. in units, in world coordinates, converted to meters
Returns
MOAIBox2DBody joint
addDistanceJoint

Create and add a joint to the world. See Box2D documentation.


function addDistanceJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number anchorA_X, number anchorA_Y, number anchorB_X, number anchorB_Y [, number frequencyHz, number dampingRatio, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numberanchorA_X in units, in world coordinates, converted to meters
numberanchorA_Y in units, in world coordinates, converted to meters
numberanchorB_X in units, in world coordinates, converted to meters
numberanchorB_Y in units, in world coordinates, converted to meters
numberfrequencyHz Optional. in Hz. Default value determined by Box2D
numberdampingRatio Optional. Default value determined by Box2D
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addFrictionJoint

Create and add a joint to the world. See Box2D documentation.


function addFrictionJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number anchorX, number anchorY [, number maxForce, number maxTorque, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numberanchorX in units, in world coordinates, converted to meters
numberanchorY in units, in world coordinates, converted to meters
numbermaxForce Optional. in kg * units / s^2, converted to N [kg * m / s^2]. Default value determined by Box2D
numbermaxTorque Optional. in kg * units / s^2 * units, converted to N-m [kg * m / s^2 * m]. Default value determined by Box2D
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addGearJoint

Create and add a joint to the world. See Box2D documentation.


function addGearJoint ( MOAIBox2DWorld self, MOAIBox2DJoint jointA, MOAIBox2DJoint jointB, number ratio [, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DJointjointA
MOAIBox2DJointjointB
numberratio
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addMotorJoint

Create and add a joint to the world. See Box2D documentation.


function addMotorJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB [, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addMouseJoint

Create and add a joint to the world. See Box2D documentation.


function addMouseJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number targetX, number targetY, number maxForce [, number frequencyHz, number dampingRatio, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numbertargetX in units, in world coordinates, converted to meters
numbertargetY in units, in world coordinates, converted to meters
numbermaxForce in kg * units / s^2, converted to N [kg * m / s^2].
numberfrequencyHz Optional. in Hz. Default value determined by Box2D
numberdampingRatio Optional. Default value determined by Box2D
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addPrismaticJoint

Create and add a joint to the world. See Box2D documentation.


function addPrismaticJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number anchorA, number anchorB, number axisA, number axisB [, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numberanchorA in units, in world coordinates, converted to meters
numberanchorB in units, in world coordinates, converted to meters
numberaxisA translation axis vector X component (no units)
numberaxisB translation axis vector Y component (no units)
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addPulleyJoint

Create and add a joint to the world. See Box2D documentation.


function addPulleyJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number groundAnchorA_X, number groundAnchorA_Y, number groundAnchorB_X, number groundAnchorB_Y, number anchorA_X, number anchorA_Y, number anchorB_X, number anchorB_Y, number ratio, number maxLengthA, number maxLengthB [, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numbergroundAnchorA_X in units, in world coordinates, converted to meters
numbergroundAnchorA_Y in units, in world coordinates, converted to meters
numbergroundAnchorB_X in units, in world coordinates, converted to meters
numbergroundAnchorB_Y in units, in world coordinates, converted to meters
numberanchorA_X in units, in world coordinates, converted to meters
numberanchorA_Y in units, in world coordinates, converted to meters
numberanchorB_X in units, in world coordinates, converted to meters
numberanchorB_Y in units, in world coordinates, converted to meters
numberratio
numbermaxLengthA in units, converted to meters
numbermaxLengthB in units, converted to meters
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addRevoluteJoint

Create and add a joint to the world. See Box2D documentation.


function addRevoluteJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number anchorX, number anchorY [, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numberanchorX in units, in world coordinates, converted to meters
numberanchorY in units, in world coordinates, converted to meters
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addRevoluteJointLocal

Create and add a joint to the world, using local anchors. See Box2D documentation.


function addRevoluteJointLocal ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number anchorA_X, number anchorA_Y, number anchorB_X, number anchorB_Y )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numberanchorA_X in units, in world coordinates, converted to meters
numberanchorA_Y in units, in world coordinates, converted to meters
numberanchorB_X in units, in world coordinates, converted to meters
numberanchorB_Y in units, in world coordinates, converted to meters
Returns
MOAIBox2DJoint joint
addRopeJoint

Create and add a rope joint to the world. See Box2D documentation.


function addRopeJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number maxLength [, number anchorAX, number anchorAY, number anchorBX, number anchorBY, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numbermaxLength in units, converted to meters
numberanchorAX Optional. in units, in world coordinates, converted to meters
numberanchorAY Optional. in units, in world coordinates, converted to meters
numberanchorBX Optional. in units, in world coordinates, converted to meters
numberanchorBY Optional. in units, in world coordinates, converted to meters
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addWeldJoint

Create and add a joint to the world. See Box2D documentation.


function addWeldJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number anchorX, number anchorY [, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numberanchorX in units, in world coordinates, converted to meters
numberanchorY in units, in world coordinates, converted to meters
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
addWheelJoint

Create and add a joint to the world. See Box2D documentation.


function addWheelJoint ( MOAIBox2DWorld self, MOAIBox2DBody bodyA, MOAIBox2DBody bodyB, number anchorX, number anchorY, number axisX, number axisY [, boolean collideConnected ] )

Parameters
MOAIBox2DWorldself
MOAIBox2DBodybodyA
MOAIBox2DBodybodyB
numberanchorX in units, in world coordinates, converted to meters
numberanchorY in units, in world coordinates, converted to meters
numberaxisX translation axis vector X component (no units)
numberaxisY translation axis vector Y component (no units)
booleancollideConnected Optional. Default value is false
Returns
MOAIBox2DJoint joint
getAngularSleepTolerance

See Box2D documentation.


function getAngularSleepTolerance ( MOAIBox2DWorld self )

Parameters
MOAIBox2DWorldself
Returns
number angularSleepTolerance
getAutoClearForces

See Box2D documentation.


function getAutoClearForces ( MOAIBox2DWorld self )

Parameters
MOAIBox2DWorldself
Returns
boolean autoClearForces
getGravity

See Box2D documentation.


function getGravity ( MOAIBox2DWorld self )

Parameters
MOAIBox2DWorldself
Returns
number gravityX, number gravityY
getLinearSleepTolerance

See Box2D documentation.


function getLinearSleepTolerance ( MOAIBox2DWorld self )

Parameters
MOAIBox2DWorldself
Returns
number linearSleepTolerance
getPerformance

Returns profiler numbers from box2d.


function getPerformace ( MOAIBox2DWorld self )

Parameters
MOAIBox2DWorldself
Returns
number step, number collide, number solve, number solveInit, number solveVelocity, number solvePosition, number broadphase, number solveTOI
getRayCast

return RayCast 1st point hit


function getRayCast ( MOAIBox2DWorld self, number p1x, number p1y, number p2x, number p2y )

Parameters
MOAIBox2DWorldself
numberp1x
numberp1y
numberp2x
numberp2y
Returns
boolean hit, MOAIBox2DFixture fixture, number hitpointX, number hitpointY
getTimeToSleep

See Box2D documentation.


function getTimeToSleep ( MOAIBox2DWorld self )

Parameters
MOAIBox2DWorldself
Returns
number timeToSleep
setAngularSleepTolerance

See Box2D documentation.


function setAngularSleepTolerance ( MOAIBox2DWorld self [, number angularSleepTolerance ] )

Parameters
MOAIBox2DWorldself
numberangularSleepTolerance Optional. in degrees/s, converted to radians/s. Default value is 0.0f.
Returns
nil
setAutoClearForces

See Box2D documentation.


function setAutoClearForces ( MOAIBox2DWorld self [, boolean autoClearForces ] )

Parameters
MOAIBox2DWorldself
booleanautoClearForces Optional. Default value is 'true'
Returns
nil
setDebugDrawEnabled

enable/disable debug drawing.


function setDebugDrawEnabled ( MOAIBox2DWorld self, boolean enable )

Parameters
MOAIBox2DWorldself
booleanenable
Returns
nil
setDebugDrawFlags

Sets mask for debug drawing.


function setDebugDrawFlags ( MOAIBox2DWorld self [, number flags ] )

Parameters
MOAIBox2DWorldself
numberflags Optional. One of MOAIBox2DWorld.DEBUG_DRAW_SHAPES, MOAIBox2DWorld.DEBUG_DRAW_JOINTS, MOAIBox2DWorld.DEBUG_DRAW_BOUNDS, MOAIBox2DWorld.DEBUG_DRAW_PAIRS, MOAIBox2DWorld.DEBUG_DRAW_CENTERS. Default value is MOAIBox2DWorld.DEBUG_DRAW_DEFAULT.
Returns
nil
setGravity

See Box2D documentation.


function setGravity ( MOAIBox2DWorld self [, number gravityX, number gravityY ] )

Parameters
MOAIBox2DWorldself
numbergravityX Optional. in units/s^2, converted to m/s^2. Default value is 0.
numbergravityY Optional. in units/s^2, converted to m/s^2. Default value is 0.
Returns
nil
setIterations

See Box2D documentation.


function setIterations ( MOAIBox2DWorld self [, number velocityIteratons, number positionIterations ] )

Parameters
MOAIBox2DWorldself
numbervelocityIteratons Optional. Default value is current value of velocity iterations.
numberpositionIterations Optional. Default value is current value of positions iterations.
Returns
nil
setLinearSleepTolerance

See Box2D documentation.


function setLinearSleepTolerance ( MOAIBox2DWorld self [, number linearSleepTolerance ] )

Parameters
MOAIBox2DWorldself
numberlinearSleepTolerance Optional. in units/s, converted to m/s. Default value is 0.0f.
Returns
nil
setTimeToSleep

See Box2D documentation.


function setTimeToSleep ( MOAIBox2DWorld self [, number timeToSleep ] )

Parameters
MOAIBox2DWorldself
numbertimeToSleep Optional. Default value is 0.0f.
Returns
nil
setUnitsToMeters

Sets a scale factor for converting game world units to Box2D meters.


function setUnitsToMeters ( MOAIBox2DWorld self [, number unitsToMeters ] )

Parameters
MOAIBox2DWorldself
numberunitsToMeters Optional. Default value is 1.
Returns
nil