lua.wetgenes.chipmunk.shape
shape=chipmunk.shape(body,form...)
Create a shape, added to the given body. Shapes are always added to a body but must be added to a space before they have any effect. So it is normally preferable to use the body:shape function which will automatically add the shape into the space that the body belongs to.
shape=chipmunk.shape(space.static,form...)
Create a static shape in world space. We use space.static as the body.
shape=chipmunk.shape(body,"circle",radius,x,y)
Form of "circle" needs a radius and a centre point.
shape=chipmunk.shape(body,"segment",ax,ay,bx,by,radius)
Form of "segment" needs two points and a radius.
shape=chipmunk.shape(body,"poly",{x1,y1,x2,y2,...},radius)
Form of "poly" is a generic polygon defined by a table of points.
shape=chipmunk.shape(body,"box",minx,miny,maxx,maxy,radius)
Form of "box" needs two points for opposite corners, lowest pair followed by highest pair and a radius. The radius should be 0 unless you want rounded corners
lua.wetgenes.chipmunk.shape.bounding_box
min_x,min_y,max_x,max_y=shape:bounding_box()
Get the current bounding box for this shape.
lua.wetgenes.chipmunk.shape.collision_type
f=shape:collision_type()
f=shape:collision_type(f)
Get and/or Set the collision type for this shape.
The f argument can be a string in which case it will be converted to a number via the space:type function.
lua.wetgenes.chipmunk.shape.elasticity
f=shape:elasticity()
f=shape:elasticity(f)
Get and/or Set the elasticity for this shape.
lua.wetgenes.chipmunk.shape.filter
f=shape:filter()
f=shape:filter(f)
Get and/or Set the filter for this shape.
lua.wetgenes.chipmunk.shape.friction
f=shape:friction()
f=shape:friction(f)
Get and/or Set the friction for this shape.
lua.wetgenes.chipmunk.shape.query_point
item = shape:query_point(x,y)
Find the nearest point on the shape from the point at x,y.
returns a table with the following info or nil for no hit
it.shape -- the shape
it.point_x -- the point of contact (x)
it.point_y -- the point of contact (y)
it.distance -- the distance to the point of contact
it.gradient_x -- the normalised vector to collision (x)
it.gradient_y -- the normalised vector to collision (y)
lua.wetgenes.chipmunk.shape.query_segment
it = shape:query_segment(sx,sy,ex,ey,r)
Find the hitpoint along this raycast segment, from (sx,sy) to (ex,ey) with a radius of r.
Returns a table with the following info or nil for no hit
it.shape -- the shape
it.point_x -- the point of contact (x)
it.point_y -- the point of contact (y)
it.normal_x -- the normal at contact (x)
it.normal_y -- the normal at contact (y)
it.alpha -- how far along the segment the contact happened (0 to 1)
lua.wetgenes.chipmunk.shape.radius
radius=shape:radius()
radius=shape:radius(radius)
Get and/or Set the radius for this shape. Setting is unsafe and may break the physics simulation.
lua.wetgenes.chipmunk.shape.sensor
f=shape:sensor()
f=shape:sensor(f)
Get and/or Set the sensor flag for this shape.
lua.wetgenes.chipmunk.shape.surface_velocity
vx,vy=shape:surface_velocity()
vx,vy=shape:surface_velocity(vx,vy)
Get and/or Set the surface velocity for this shape.