Moai SDK  1.5 revision 1 (MoaiEdition)
MOAICpBody Class Reference
Inheritance diagram for MOAICpBody:
MOAITransformBase MOAINode MOAIInstanceEventSource MOAIEventSource

List of all members.

Function List

  activate
  addCircle
  addPolygon
  addRect
  addSegment
  applyForce
  applyImpulse
  getAngle
  getAngVel
  getForce
  getMass
  getMoment
  getPos
  getRot
  getTorque
  getVel
  isSleeping
  isStatic
  isRogue
  localToWorld
  new
  newStatic
  resetForces
  setAngle
  setAngVel
  setForce
  setMass
  setMoment
  setPos
  setRemoveFlag
  setTorque
  setVel
  sleep
  sleepWithGroup
  worldToLocal

Function Documentation

Activates a body after it has been put to sleep (physics will now be processed for this body again).


function activate ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
nil

Adds a circle to the body.


function addCircle ( MOAICpBody self, number radius, number x, number y )
Parameters:
self ( MOAICpBody )
radius ( number )
x ( number )
y ( number )
Returns:
circle ( MOAICpShape )

Adds a polygon to the body.


function addPolygon ( MOAICpBody self, table polygon )
Parameters:
self ( MOAICpBody )
polygon ( table )
Returns:
polygon ( MOAICpShape )

Adds a rectangle to the body.


function addRect ( MOAICpBody self, number x1, number y1, number x2, number y2 )
Parameters:
self ( MOAICpBody )
x1 ( number )
y1 ( number )
x2 ( number )
y2 ( number )
Returns:
rectangle ( MOAICpShape )

Adds a segment to the body.


function addSegment ( MOAICpBody self, number x1, number y1, number x2, number y2 [, number radius ] )
Parameters:
self ( MOAICpBody )
x1 ( number )
y1 ( number )
x2 ( number )
y2 ( number )
radius ( number ) Optional.
Returns:
segment ( MOAICpShape )

Applies force to the body, taking into account any existing forces being applied.


function applyForce ( MOAICpBody self, number fx, number fy, number rx, number ry )
Parameters:
self ( MOAICpBody )
fx ( number )
fy ( number )
rx ( number )
ry ( number )
Returns:
nil

Applies impulse to the body, taking into account any existing impulses being applied.


function applyImpulse ( MOAICpBody self, number jx, number jy, number rx, number ry )
Parameters:
self ( MOAICpBody )
jx ( number )
jy ( number )
rx ( number )
ry ( number )
Returns:
nil

Returns the angle of the body.


function getAngle ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
angle ( number )

Returns the angular velocity of the body.


function getAngVel ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
angle ( number )

Returns the force of the body.


function getForce ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
x ( number ), y ( number )

Returns the mass of the body.


function getMass ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
mass ( number )

Returns the moment of the body.


function getMoment ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
moment ( number )

Returns the position of the body.


function getPos ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
x ( number ), y ( number )

Returns the rotation of the body.


function getRot ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
x ( number ), y ( number )

Returns the torque of the body.


function getTorque ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
torque ( number )

Returns the velocity of the body.


function getVel ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
x ( number ), y ( number )

Returns whether the body is not yet currently associated with a space.


function isRogue ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
static ( boolean )

Returns whether the body is currently sleeping.


function isSleeping ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
sleeping ( boolean )

Returns whether the body is static.


function isStatic ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
static ( boolean )

Converts the relative position to an absolute position based on position of the object being (0, 0) for the relative position.


function localToWorld ( MOAICpBody self, number rx, number ry )
Parameters:
self ( MOAICpBody )
rx ( number ) The relative X position.
ry ( number ) The relative Y position.
Returns:
ax ( number ), ay ( number )
new

Creates a new body with the specified mass and moment.


function new ( number m, number i )
Parameters:
m ( number ) The mass of the new body.
i ( number ) The moment of the new body.
Returns:
body ( MOAICpBody )

Creates a new static body.


function newStatic ()
Returns:
body ( MOAICpBody )

Resets all forces on the body.


function resetForces ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
nil

Sets the angle of the body.


function setAngle ( MOAICpBody self, number angle )
Parameters:
self ( MOAICpBody )
angle ( number ) The angle of the body.
Returns:
nil

Sets the angular velocity of the body.


function setAngVel ( MOAICpBody self, number angvel )
Parameters:
self ( MOAICpBody )
angvel ( number ) The angular velocity of the body.
Returns:
nil

Sets the force on the body.


function setForce ( MOAICpBody self, number forcex, number forcey )
Parameters:
self ( MOAICpBody )
forcex ( number ) The X force being applied to the body.
forcey ( number ) The Y force being applied to the body.
Returns:
nil

Sets the mass of the body.


function setMass ( MOAICpBody self, number mass )
Parameters:
self ( MOAICpBody )
mass ( number ) The mass of the body.
Returns:
nil

Sets the moment of the body.


function setMoment ( MOAICpBody self, number moment )
Parameters:
self ( MOAICpBody )
moment ( number ) The moment of the body.
Returns:
nil

Sets the position of the body.


function setPos ( MOAICpBody self, number x, number y )
Parameters:
self ( MOAICpBody )
x ( number ) The X position of the body.
y ( number ) The Y position of the body.
Returns:
nil

Sets the removal flag on the body.


function setRemoveFlag ( MOAICpBody self, number flag )
Parameters:
self ( MOAICpBody )
flag ( number ) The removal flag.
Returns:
nil

Sets the torque of the body.


function setTorque ( MOAICpBody self, number torque )
Parameters:
self ( MOAICpBody )
torque ( number ) The torque of the body.
Returns:
nil

Sets the velocity of the body.


function setVel ( MOAICpBody self, number x, number y )
Parameters:
self ( MOAICpBody )
x ( number ) The horizontal velocity.
y ( number ) The vertical velocity.
Returns:
nil

Puts the body to sleep (physics will no longer be processed for it until it is activated).


function sleep ( MOAICpBody self )
Parameters:
self ( MOAICpBody )
Returns:
nil

Forces an object to sleep. Pass in another sleeping body to add the object to the sleeping body's existing group.


function sleepWithGroup ( MOAICpBody self, MOAICpBody group )
Parameters:
self ( MOAICpBody )
group ( MOAICpBody )
Returns:
nil

Converts the absolute position to a relative position based on position of the object being (0, 0) for the relative position.


function worldToLocal ( MOAICpBody self, number ax, number ay )
Parameters:
self ( MOAICpBody )
ax ( number ) The absolute X position.
ay ( number ) The absolute Y position.
Returns:
rx ( number ), ry ( number )