q5play
    Preparing search index...

    Class GlueJoint

    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

    Constructors

    Properties

    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
    

    Accessors

    • get collideConnected(): boolean

      Set to true if you want the joint's sprites to collide with each other.

      Returns boolean

      false
      
    • set collideConnected(val: boolean): void

      Parameters

      • val: boolean

      Returns void

    • get draw(): Function

      Function that draws the joint. Can be overridden by the user.

      Returns Function

    • set draw(val: Function): void

      Parameters

      • val: Function

      Returns void

    • 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 offsetA(): Vector

      Offset to the joint's anchorA position from the center of spriteA.

      Only distance and hinge joints have an offsetA.

      Returns Vector

      {x: 0, y: 0}
      
    • set offsetA(val: [] | Vector | { x: number; y: number }): void

      Parameters

      • val: [] | Vector | { x: number; y: number }

      Returns void

    • get offsetB(): Vector

      Offset to the joint's anchorB position from the center of spriteB.

      Only distance, hinge, and wheel joints have an offsetB.

      Returns Vector

      {x: 0, y: 0}
      
    • set offsetB(val: [] | Vector | { x: number; y: number }): void

      Parameters

      • val: [] | Vector | { x: number; y: number }

      Returns void

    • get reactionForce(): any

      How much force the joint is applying to keep the two sprites together.

      Returns any

    • get reactionTorque(): any

      How much torque the joint is applying to keep the two sprites together.

      Returns any

    • get springiness(): number

      Returns number

    • set springiness(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

    Methods

    • Deletes the joint from the world and from each of the associated sprites' joints arrays.

      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