Physics.P2#createSpring()

createSpring(bodyA, bodyB, restLength, stiffness, damping, worldA, worldB, localA, localB) → {Phaser.Physics.P2.Spring}

Creates a linear spring, connecting two bodies. A spring can have a resting length, a stiffness and damping.

Parameters
Name Type Argument Default Description
bodyA Phaser.Sprite | Phaser.Physics.P2.Body | p2.Body

First connected body.

bodyB Phaser.Sprite | Phaser.Physics.P2.Body | p2.Body

Second connected body.

restLength number <optional>
1

Rest length of the spring. A number > 0.

stiffness number <optional>
100

Stiffness of the spring. A number >= 0.

damping number <optional>
1

Damping of the spring. A number >= 0.

worldA Array <optional>

Where to hook the spring to body A in world coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32].

worldB Array <optional>

Where to hook the spring to body B in world coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32].

localA Array <optional>

Where to hook the spring to body A in local body coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32].

localB Array <optional>

Where to hook the spring to body B in local body coordinates. This value is an array by 2 elements, x and y, i.e: [32, 32].

Returns
Source code: physics/p2/World.js (Line 1484)
doc_phaser
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.