q5play
    Preparing search index...

    Class Joint

    A Joint is used to constrain the movement of two sprites relative to each other, which can lead to nuanced physics interactions.

    Hierarchy (View Summary)

    Index
    • Don't use the Joint constructor directly, use one of these joint constructors instead:

      GlueJoint, DistanceJoint, WheelJoint, HingeJoint, SliderJoint, or GrabberJoint.

      Parameters

      Returns Joint

    The Box2D joint ID. Don't change it!

    spriteA: Sprite

    The first sprite in the joint.

    spriteB: Sprite

    The second sprite in the joint.

    type: string

    The type of joint. Can be one of:

    "glue", "distance", "wheel", "hinge", "slider", or "grabber".

    Can't be changed after the joint is created.

    visible: boolean

    Determines whether to draw the joint if spriteA or spriteB is drawn.

    true
    
    • get forceThreshold(): number

      The amount of force that must be applied to the joint before it breaks.

      Setting the threshold too high leads to instability. Use sprite.addCollider to simulate unbreakable bonds between shapes.

      Returns number

      500
      
    • set forceThreshold(val: number): void

      Parameters

      • val: number

      Returns void

    • get torqueThreshold(): number

      The amount of torque that must be applied to the joint before it breaks.

      Setting the threshold too high leads to instability. Use sprite.addCollider to simulate unbreakable bonds between shapes.

      Returns number

      500
      
    • set torqueThreshold(val: number): void

      Parameters

      • val: number

      Returns void

    • This function is run when the joint's reaction force exceeds the force threshold or its reaction torque exceeds the torque threshold.

      By default, the sprites' speed and rotation speed are set to 0 and the joint is deleted, simulating a break.

      Returns void