lua.wetgenes.chipmunk.body
body=chipmunk.body(mass,inertia)
Create a dynamic body, with the given mass and inertia.
You will need to add the body to a space before it exists so it is normally preferable to use the space:body function which will call this function and then automatically add the body into the space.
body=chipmunk.body("kinematic")
Create a kinematic body, these are bodies that we can move around, by setting its velocity, but are not effected by collisions with other bodies. EG a moving platform.
body=chipmunk.body("static")
Create a static body, mostly you can just use space.static as the default static body but you may create more if you wish to group your static shapes into multiple bodies.
lua.wetgenes.chipmunk.body.angle
a=body:angle()
a=body:angle(a)
Get and/or Set the rotation angle in radians for this body.
lua.wetgenes.chipmunk.body.angular_velocity
a=body:angular_velocity()
a=body:angular_velocity(a)
Get and/or Set the angular velocity in radians for this body.
lua.wetgenes.chipmunk.body.apply_force
body:apply_force(fx,fy,px,py)
body:apply_force(fx,fy,px,py,"world")
Apply a force to this body at a specific point, the point can be in world coordinates if you include the "world" flag but defaults to local object coordinates.
lua.wetgenes.chipmunk.body.apply_impulse
body:apply_impulse(ix,iy,px,py)
body:apply_impulse(ix,iy,px,py,"world")
Apply a force to this body at a specific point, the point can be in world coordinates if you include the "world" flag but defaults to local object coordinates.
lua.wetgenes.chipmunk.body.center_of_gravity
vx,vy=body:center_of_gravity()
vx,vy=body:center_of_gravity(vx,vy)
Get and/or Set the center of gravity for this body.
lua.wetgenes.chipmunk.body.force
vx,vy=body:force()
vx,vy=body:force(vx,vy)
Get and/or Set the force for this body. This is reset back to 0 after each step.
lua.wetgenes.chipmunk.body.mass
m=body:mass()
m=body:mass(m)
Get and/or Set the mass for this body.
lua.wetgenes.chipmunk.body.moment
m=body:moment()
m=body:moment(m)
Get and/or Set the moment for this body.
lua.wetgenes.chipmunk.body.position
vx,vy=body:position()
vx,vy=body:position(vx,vy)
Get and/or Set the position for this body.
lua.wetgenes.chipmunk.body.position_func
body:position_func(position_callback)
body:position_func()
Set or clear the position callback update function for this body.
position_callback(body)
body.delta_time
This callback will be called with the above values set into body, you can adjust these and return true to perform a normal position update but with these new values.
Alternatively you can update the bodys position directly and return false so the normal position update code will not be run.
lua.wetgenes.chipmunk.body.shape
shape=body:shape(form,...)
Add a new shape to this body, returns the shape for further modification.
lua.wetgenes.chipmunk.body.torque
a=body:torque()
a=body:torque(a)
Get and/or Set the torque for this body.
lua.wetgenes.chipmunk.body.type
t=body:type()
t=body:type(t)
Get and/or Set the type for this body.
lua.wetgenes.chipmunk.body.velocity
vx,vy=body:velocity()
vx,vy=body:velocity(vx,vy)
Get and/or Set the velocity for this body.
lua.wetgenes.chipmunk.body.velocity_func
body:velocity_func(velocity_callback)
body:velocity_func()
Set or clear the velocity callback update function for this body.
velocity_callback(body)
body.gravity_x
body.gravity_y
body.damping
body.delta_time
This callback will be called with the above values set into body, you can adjust these and return true to perform a normal velocity update but with these new values.
IE you can choose a new gravity vector for this body which is the simplest change to make.
Alternatively you can update the bodys velocity directly and return false so the normal velocity update code will not be run.