b2d.joint

Namespace: b2d.joint Language: Lua Type: Defold Lua File: script_box2d_joint_v2.cpp Source: engine/gamesys/src/gamesys/scripts/box2d/v2/script_box2d_joint_v2.cpp

Functions for interacting with native Box2D joints.

API

b2d.joint.create_distance

Type: FUNCTION Create a distance joint.

Parameters

Returns

b2d.joint.create_distance

Type: FUNCTION Create a distance joint.

Parameters

Returns

b2d.joint.create_filter

Type: FUNCTION Create a filter joint.

Parameters

Returns

b2d.joint.create_friction

Type: FUNCTION Create a friction joint.

Parameters

Returns

b2d.joint.create_gear

Type: FUNCTION Create a gear joint.

Parameters

Returns

b2d.joint.create_motor

Type: FUNCTION Create a motor joint.

Parameters

Returns

b2d.joint.create_mouse

Type: FUNCTION Create a mouse joint.

Parameters

Returns

b2d.joint.create_mouse

Type: FUNCTION Create a mouse joint.

Parameters

Returns

b2d.joint.create_prismatic

Type: FUNCTION Create a prismatic joint.

Parameters

Returns

b2d.joint.create_prismatic

Type: FUNCTION Create a prismatic joint.

Parameters

Returns

b2d.joint.create_pulley

Type: FUNCTION Create a pulley joint.

Parameters

Returns

b2d.joint.create_revolute

Type: FUNCTION Create a revolute joint.

Parameters

Returns

b2d.joint.create_revolute

Type: FUNCTION Create a revolute joint.

Parameters

Returns

b2d.joint.create_rope

Type: FUNCTION Create a rope joint.

Parameters

Returns

b2d.joint.create_weld

Type: FUNCTION Create a weld joint.

Parameters

Returns

b2d.joint.create_weld

Type: FUNCTION Create a weld joint.

Parameters

Returns

b2d.joint.create_wheel

Type: FUNCTION Create a wheel joint.

Parameters

Returns

b2d.joint.create_wheel

Type: FUNCTION Create a wheel joint.

Parameters

Returns

b2d.joint.destroy

Type: FUNCTION Destroy a joint created by b2d.joint.

Parameters

b2d.joint.destroy

Type: FUNCTION Destroy a joint created by b2d.joint.

Parameters

b2d.joint.enable_limit

Type: FUNCTION Enable or disable joint limits.

Parameters

b2d.joint.enable_limit

Type: FUNCTION Enable or disable joint limits.

Parameters

b2d.joint.enable_motor

Type: FUNCTION Enable or disable the joint motor.

Parameters

b2d.joint.enable_motor

Type: FUNCTION Enable or disable the joint motor.

Parameters

b2d.joint.enable_spring

Type: FUNCTION Enable or disable joint spring behavior.

Parameters

b2d.joint.get_anchor_a

Type: FUNCTION Get the world anchor on body A.

Parameters

Returns

b2d.joint.get_anchor_a

Type: FUNCTION Get the world anchor on body A.

Parameters

Returns

b2d.joint.get_anchor_b

Type: FUNCTION Get the world anchor on body B.

Parameters

Returns

b2d.joint.get_anchor_b

Type: FUNCTION Get the world anchor on body B.

Parameters

Returns

b2d.joint.get_angular_damping_ratio

Type: FUNCTION Get weld joint angular damping ratio.

Parameters

Returns

b2d.joint.get_angular_hertz

Type: FUNCTION Get weld joint angular frequency.

Parameters

Returns

b2d.joint.get_angular_offset

Type: FUNCTION Get motor joint angular offset.

Parameters

Returns

b2d.joint.get_body_a

Type: FUNCTION Get the first body connected to a joint.

Parameters

Returns

b2d.joint.get_body_a

Type: FUNCTION Get the first body connected to a joint.

Parameters

Returns

b2d.joint.get_body_b

Type: FUNCTION Get the second body connected to a joint.

Parameters

Returns

b2d.joint.get_body_b

Type: FUNCTION Get the second body connected to a joint.

Parameters

Returns

b2d.joint.get_collide_connected

Type: FUNCTION Get whether connected bodies can collide.

Parameters

Returns

b2d.joint.get_collide_connected

Type: FUNCTION Get whether connected bodies can collide.

Parameters

Returns

b2d.joint.get_correction_factor

Type: FUNCTION Get motor joint correction factor.

Parameters

Returns

b2d.joint.get_current_length

Type: FUNCTION Get the current distance joint length.

Parameters

Returns

b2d.joint.get_damping_ratio

Type: FUNCTION Get spring damping ratio.

Parameters

Returns

b2d.joint.get_damping_ratio

Type: FUNCTION Alias for b2d.joint.get_spring_damping_ratio.

Parameters

Returns

b2d.joint.get_frequency

Type: FUNCTION Get spring frequency.

Parameters

Returns

b2d.joint.get_frequency

Type: FUNCTION Alias for b2d.joint.get_spring_hertz.

Parameters

Returns

b2d.joint.get_ground_anchor_a

Type: FUNCTION Get pulley ground anchor A.

Parameters

Returns

b2d.joint.get_ground_anchor_b

Type: FUNCTION Get pulley ground anchor B.

Parameters

Returns

b2d.joint.get_hertz

Type: FUNCTION Alias for b2d.joint.get_frequency.

Parameters

Returns

b2d.joint.get_hertz

Type: FUNCTION Alias for b2d.joint.get_spring_hertz.

Parameters

Returns

b2d.joint.get_joint1

Type: FUNCTION Get the first joint connected to a gear joint.

Parameters

Returns

b2d.joint.get_joint2

Type: FUNCTION Get the second joint connected to a gear joint.

Parameters

Returns

b2d.joint.get_joint_angle

Type: FUNCTION Get revolute joint angle.

Parameters

Returns

b2d.joint.get_joint_angle

Type: FUNCTION Get revolute joint angle.

Parameters

Returns

b2d.joint.get_joint_speed

Type: FUNCTION Get joint speed.

Parameters

Returns

b2d.joint.get_joint_speed

Type: FUNCTION Get joint speed.

Parameters

Returns

b2d.joint.get_joint_translation

Type: FUNCTION Get joint translation.

Parameters

Returns

b2d.joint.get_joint_translation

Type: FUNCTION Get joint translation.

Parameters

Returns

b2d.joint.get_length

Type: FUNCTION Get the distance joint length.

Parameters

Returns

b2d.joint.get_length

Type: FUNCTION Get the distance joint length.

Parameters

Returns

b2d.joint.get_length_a

Type: FUNCTION Get pulley segment length A.

Parameters

Returns

b2d.joint.get_length_b

Type: FUNCTION Get pulley segment length B.

Parameters

Returns

b2d.joint.get_limit_state

Type: FUNCTION Get rope limit state.

Parameters

Returns

b2d.joint.get_linear_damping_ratio

Type: FUNCTION Get weld joint linear damping ratio.

Parameters

Returns

b2d.joint.get_linear_hertz

Type: FUNCTION Get weld joint linear frequency.

Parameters

Returns

b2d.joint.get_linear_offset

Type: FUNCTION Get motor joint linear offset.

Parameters

Returns

b2d.joint.get_local_anchor_a

Type: FUNCTION Get the local anchor on body A.

Parameters

Returns

b2d.joint.get_local_anchor_a

Type: FUNCTION Get the local anchor on body A.

Parameters

Returns

b2d.joint.get_local_anchor_b

Type: FUNCTION Get the local anchor on body B.

Parameters

Returns

b2d.joint.get_local_anchor_b

Type: FUNCTION Get the local anchor on body B.

Parameters

Returns

b2d.joint.get_local_axis_a

Type: FUNCTION Get the local axis on body A.

Parameters

Returns

b2d.joint.get_lower_limit

Type: FUNCTION Get the lower joint limit.

Parameters

Returns

b2d.joint.get_lower_limit

Type: FUNCTION Get the lower joint limit.

Parameters

Returns

b2d.joint.get_max_force

Type: FUNCTION Get maximum force.

Parameters

Returns

b2d.joint.get_max_force

Type: FUNCTION Get maximum force.

Parameters

Returns

b2d.joint.get_max_length

Type: FUNCTION Get rope maximum length.

Parameters

Returns

b2d.joint.get_max_length

Type: FUNCTION Get the distance joint maximum length.

Parameters

Returns

b2d.joint.get_max_motor_force

Type: FUNCTION Get maximum motor force.

Parameters

Returns

b2d.joint.get_max_motor_force

Type: FUNCTION Get maximum motor force.

Parameters

Returns

b2d.joint.get_max_motor_torque

Type: FUNCTION Get maximum motor torque.

Parameters

Returns

b2d.joint.get_max_motor_torque

Type: FUNCTION Get maximum motor torque.

Parameters

Returns

b2d.joint.get_max_torque

Type: FUNCTION Get maximum torque.

Parameters

Returns

b2d.joint.get_max_torque

Type: FUNCTION Get maximum torque.

Parameters

Returns

b2d.joint.get_min_length

Type: FUNCTION Get the distance joint minimum length.

Parameters

Returns

b2d.joint.get_motor_force

Type: FUNCTION Get current motor force.

Parameters

Returns

b2d.joint.get_motor_force

Type: FUNCTION Get current motor force.

Parameters

Returns

b2d.joint.get_motor_speed

Type: FUNCTION Get motor speed.

Parameters

Returns

b2d.joint.get_motor_speed

Type: FUNCTION Get motor speed.

Parameters

Returns

b2d.joint.get_motor_torque

Type: FUNCTION Get current motor torque.

Parameters

Returns

b2d.joint.get_motor_torque

Type: FUNCTION Get current motor torque.

Parameters

Returns

b2d.joint.get_mouse_target

Type: FUNCTION Get the target for a mouse joint.

Parameters

Returns

b2d.joint.get_mouse_target

Type: FUNCTION Get the target for a mouse joint.

Parameters

Returns

b2d.joint.get_ratio

Type: FUNCTION Get joint ratio.

Parameters

Returns

b2d.joint.get_reaction_force

Type: FUNCTION Get reaction force.

Parameters

Returns

b2d.joint.get_reaction_force

Type: FUNCTION Get reaction force.

Parameters

Returns

b2d.joint.get_reaction_torque

Type: FUNCTION Get reaction torque.

Parameters

Returns

b2d.joint.get_reaction_torque

Type: FUNCTION Get reaction torque.

Parameters

Returns

b2d.joint.get_reference_angle

Type: FUNCTION Get the reference angle.

Parameters

Returns

b2d.joint.get_reference_angle

Type: FUNCTION Get weld joint reference angle.

Parameters

Returns

b2d.joint.get_spring_damping_ratio

Type: FUNCTION Alias for b2d.joint.get_damping_ratio.

Parameters

Returns

b2d.joint.get_spring_damping_ratio

Type: FUNCTION Get spring damping ratio.

Parameters

Returns

b2d.joint.get_spring_hertz

Type: FUNCTION Get spring frequency.

Parameters

Returns

b2d.joint.get_type

Type: FUNCTION Get the joint type.

Parameters

Returns

b2d.joint.get_type

Type: FUNCTION Get the joint type.

Parameters

Returns

b2d.joint.get_upper_limit

Type: FUNCTION Get the upper joint limit.

Parameters

Returns

b2d.joint.get_upper_limit

Type: FUNCTION Get the upper joint limit.

Parameters

Returns

b2d.joint.get_world

Type: FUNCTION Get the world owning a joint.

Parameters

Returns

b2d.joint.is_active

Type: FUNCTION Get whether the joint is active.

Parameters

Returns

b2d.joint.is_limit_enabled

Type: FUNCTION Get whether joint limits are enabled.

Parameters

Returns

b2d.joint.is_limit_enabled

Type: FUNCTION Get whether joint limits are enabled.

Parameters

Returns

b2d.joint.is_motor_enabled

Type: FUNCTION Get whether the joint motor is enabled.

Parameters

Returns

b2d.joint.is_motor_enabled

Type: FUNCTION Get whether the joint motor is enabled.

Parameters

Returns

b2d.joint.is_spring_enabled

Type: FUNCTION Get whether joint spring behavior is enabled.

Parameters

Returns

b2d.joint.is_valid

Type: FUNCTION Validate a joint handle.

Parameters

Returns

b2d.joint.JOINT_TYPE

Type: ENUM Box2D joint types.

Members

b2d.joint.LIMIT_STATE

Type: ENUM Box2D joint limit states.

Members

b2d.joint.set_angular_damping_ratio

Type: FUNCTION Set weld joint angular damping ratio.

Parameters

b2d.joint.set_angular_hertz

Type: FUNCTION Set weld joint angular frequency.

Parameters

b2d.joint.set_angular_offset

Type: FUNCTION Set motor joint angular offset.

Parameters

b2d.joint.set_collide_connected

Type: FUNCTION Set whether connected bodies can collide.

Parameters

b2d.joint.set_correction_factor

Type: FUNCTION Set motor joint correction factor.

Parameters

b2d.joint.set_damping_ratio

Type: FUNCTION Set spring damping ratio.

Parameters

b2d.joint.set_damping_ratio

Type: FUNCTION Alias for b2d.joint.set_spring_damping_ratio.

Parameters

b2d.joint.set_frequency

Type: FUNCTION Set spring frequency.

Parameters

b2d.joint.set_frequency

Type: FUNCTION Alias for b2d.joint.set_spring_hertz.

Parameters

b2d.joint.set_hertz

Type: FUNCTION Alias for b2d.joint.set_frequency.

Parameters

b2d.joint.set_hertz

Type: FUNCTION Alias for b2d.joint.set_spring_hertz.

Parameters

b2d.joint.set_length

Type: FUNCTION Set the distance joint length.

Parameters

b2d.joint.set_length

Type: FUNCTION Set the distance joint length.

Parameters

b2d.joint.set_length_range

Type: FUNCTION Set the distance joint length range.

Parameters

b2d.joint.set_limits

Type: FUNCTION Set joint limits.

Parameters

b2d.joint.set_limits

Type: FUNCTION Set joint limits.

Parameters

b2d.joint.set_linear_damping_ratio

Type: FUNCTION Set weld joint linear damping ratio.

Parameters

b2d.joint.set_linear_hertz

Type: FUNCTION Set weld joint linear frequency.

Parameters

b2d.joint.set_linear_offset

Type: FUNCTION Set motor joint linear offset.

Parameters

b2d.joint.set_max_force

Type: FUNCTION Set maximum force.

Parameters

b2d.joint.set_max_force

Type: FUNCTION Set maximum force.

Parameters

b2d.joint.set_max_length

Type: FUNCTION Set rope maximum length.

Parameters

b2d.joint.set_max_length

Type: FUNCTION Set the distance joint maximum length.

Parameters

b2d.joint.set_max_motor_force

Type: FUNCTION Set maximum motor force.

Parameters

b2d.joint.set_max_motor_force

Type: FUNCTION Set maximum motor force.

Parameters

b2d.joint.set_max_motor_torque

Type: FUNCTION Set maximum motor torque.

Parameters

b2d.joint.set_max_motor_torque

Type: FUNCTION Set maximum motor torque.

Parameters

b2d.joint.set_max_torque

Type: FUNCTION Set maximum torque.

Parameters

b2d.joint.set_max_torque

Type: FUNCTION Set maximum torque.

Parameters

b2d.joint.set_min_length

Type: FUNCTION Set the distance joint minimum length.

Parameters

b2d.joint.set_motor_speed

Type: FUNCTION Set motor speed.

Parameters

b2d.joint.set_motor_speed

Type: FUNCTION Set motor speed.

Parameters

b2d.joint.set_mouse_target

Type: FUNCTION Set the target for a mouse joint.

Parameters

b2d.joint.set_mouse_target

Type: FUNCTION Set the target for a mouse joint.

Parameters

b2d.joint.set_ratio

Type: FUNCTION Set gear joint ratio.

Parameters

b2d.joint.set_reference_angle

Type: FUNCTION Set weld joint reference angle.

Parameters

b2d.joint.set_spring_damping_ratio

Type: FUNCTION Alias for b2d.joint.set_damping_ratio.

Parameters

b2d.joint.set_spring_damping_ratio

Type: FUNCTION Set spring damping ratio.

Parameters

b2d.joint.set_spring_hertz

Type: FUNCTION Set spring frequency.

Parameters

b2d.joint.wake_bodies

Type: FUNCTION Wake the bodies connected to a joint.

Parameters

b2Joint

Type: TYPEDEF An opaque handle connecting two b2Body values. Create one with a function such as b2d.joint.create_distance, use the functions in b2d.joint to inspect or configure it, and release it with b2d.joint.destroy. Joints are also destroyed when either connected body or its physics world is destroyed.

Parameters

Examples

local body_a = b2d.get_body("#collisionobject_a")
local body_b = b2d.get_body("#collisionobject_b")
local joint = b2d.joint.create_distance(body_a, body_b)
print(b2d.joint.get_type(joint))

b2Joint

Type: TYPEDEF An opaque handle connecting two b2Body values. Create one with a function such as b2d.joint.create_distance, use the functions in b2d.joint to inspect or configure it, and release it with b2d.joint.destroy. Use b2d.joint.is_valid before retaining a handle across body or world destruction.

Parameters

Examples

local body_a = b2d.get_body("#collisionobject_a")
local body_b = b2d.get_body("#collisionobject_b")
local joint = b2d.joint.create_distance(body_a, body_b)
if b2d.joint.is_valid(joint) then
    print(b2d.joint.get_type(joint))
end