Functions for Box2D v3 chains. A chain owns multiple connected segment
shapes, so it is represented by a separate b2Chain handle.
Version: beta
| FUNCTIONS | |
|---|---|
| b2d.chain.destroy() | Destroy a chain. |
| b2d.chain.from_shape() | Get the parent chain for a chain segment shape. |
| b2d.chain.get_friction() | Get chain friction. |
| b2d.chain.get_geometry() | Get the chain geometry. |
| b2d.chain.get_material() | Get chain material id. |
| b2d.chain.get_restitution() | Get chain restitution. |
| b2d.chain.get_segment_count() | Get the number of segment shapes in a chain. |
| b2d.chain.get_segments() | Get the segment shapes owned by a chain. |
| b2d.chain.get_world() | Get the world owning a chain. |
| b2d.chain.is_valid() | Validate a chain handle. |
| b2d.chain.set_friction() | Set chain friction. |
| b2d.chain.set_material() | Set chain material id. |
| b2d.chain.set_restitution() | Set chain restitution. |
b2d.chain.destroy(chain)
Destroying a chain removes all segment shapes owned by the chain. Destroying
any segment shape through b2d.body.destroy_shape also destroys its parent chain.
PARAMETERS
chain |
b2Chain |
chain |
b2d.chain.from_shape(shape_id)
Returns nil if the shape is not a chain segment.
PARAMETERS
shape_id |
b2Shape |
shape handle from a shape info table, or pass body, shape_index |
RETURNS
chain |
b2Chainnil |
parent chain, or nil if the shape is not a chain segment |
b2d.chain.get_friction(chain)
Get chain friction.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
friction |
number |
chain friction |
b2d.chain.get_geometry(chain)
Returns a chain geometry table with loop, segment_count, and vertices.
Open chains also include prev_vertex and next_vertex ghost vertices.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
geometry |
table |
chain geometry table |
b2d.chain.get_material(chain)
Get chain material id.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
material |
number |
chain material id |
b2d.chain.get_restitution(chain)
Get chain restitution.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
restitution |
number |
chain restitution |
b2d.chain.get_segment_count(chain)
Get the number of segment shapes in a chain.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
count |
number |
segment count |
b2d.chain.get_segments(chain)
Get the segment shapes owned by a chain.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
segments |
table |
array of shape info tables for the chain segments. Each entry includes shape_id. |
b2d.chain.get_world(chain)
Get the world owning a chain.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
world |
b2World |
owning world |
b2d.chain.is_valid(chain)
Validate a chain handle.
PARAMETERS
chain |
b2Chain |
chain |
RETURNS
valid |
boolean |
true if the chain handle still refers to a live Box2D chain |
b2d.chain.set_friction(chain,friction)
Set chain friction.
PARAMETERS
chain |
b2Chain |
chain |
friction |
number |
chain friction |
b2d.chain.set_material(chain,material)
Set chain material id.
PARAMETERS
chain |
b2Chain |
chain |
material |
number |
chain material id |
b2d.chain.set_restitution(chain,restitution)
Set chain restitution.
PARAMETERS
chain |
b2Chain |
chain |
restitution |
number |
chain restitution |