Namespace: b2d.chain
Language: Lua
Type: Defold Lua
File: script_box2d_chain_v3.cpp
Source: engine/gamesys/src/gamesys/scripts/box2d/v3/script_box2d_chain_v3.cpp
Functions for Box2D v3 chains. A chain owns multiple connected segment
shapes, so it is represented by a separate b2Chain handle.
Type: TYPEDEF Box2D chain
Parameters
value (userdata)Type: FUNCTION 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) - chainType: FUNCTION 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_indexReturns
chain (b2Chain |
nil) - parent chain, or nil if the shape is not a chain segment |
Type: FUNCTION Get chain friction.
Parameters
chain (b2Chain) - chainReturns
friction (number) - chain frictionType: FUNCTION 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) - chainReturns
geometry (table) - chain geometry tableType: FUNCTION Get chain material id.
Parameters
chain (b2Chain) - chainReturns
material (number) - chain material idType: FUNCTION Get chain restitution.
Parameters
chain (b2Chain) - chainReturns
restitution (number) - chain restitutionType: FUNCTION Get the number of segment shapes in a chain.
Parameters
chain (b2Chain) - chainReturns
count (number) - segment countType: FUNCTION Get the segment shapes owned by a chain.
Parameters
chain (b2Chain) - chainReturns
segments (table) - array of shape info tables for the chain segments. Each entry includes shape_id.Type: FUNCTION Get the world owning a chain.
Parameters
chain (b2Chain) - chainReturns
world (b2World) - owning worldType: FUNCTION Validate a chain handle.
Parameters
chain (b2Chain) - chainReturns
valid (boolean) - true if the chain handle still refers to a live Box2D chainType: FUNCTION Set chain friction.
Parameters
chain (b2Chain) - chainfriction (number) - chain frictionType: FUNCTION Set chain material id.
Parameters
chain (b2Chain) - chainmaterial (number) - chain material idType: FUNCTION Set chain restitution.
Parameters
chain (b2Chain) - chainrestitution (number) - chain restitution