Class: Spring

Phaser.Physics.P2. Spring

new Spring(world, bodyA, bodyB [, restLength] [, stiffness] [, damping] [, worldA] [, worldB] [, localA] [, localB])

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

Parameters:
Name Type Argument Default Description
world Phaser.Physics.P2

A reference to the P2 World.

bodyA p2.Body

First connected body.

bodyB 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 with 2 elements matching 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 with 2 elements matching 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 with 2 elements matching 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 with 2 elements matching x and y, i.e: [32, 32].

Source:
src/physics/p2/Spring.js line 23

Members

data : p2.LinearSpring

The actual p2 spring object.

Type:
  • p2.LinearSpring
Source:
src/physics/p2/Spring.js line 70

game : Phaser.Game

Local reference to game.

Type:
Source:
src/physics/p2/Spring.js line 28

world : Phaser.Physics.P2

Local reference to P2 World.

Type:
Source:
src/physics/p2/Spring.js line 33

phaser-ce@2.9.2 is on GitHub and NPM

Documentation generated by JSDoc 3.5.4 on 2017-11-09 using Tomorrow.