Godot Nature of Code  1.2.0
Nature of Code implemented in Godot Engine
Public Member Functions | Public Attributes | List of all members
Oscillation.SimpleSpring Class Reference

Simple spring. Spring anchor is the node position. Manage children as targets. More...

Inherits Node2D.

Public Member Functions

 SimpleSpring ()
 Create a default spring. More...
 
void SetMover (SimpleMover mover, Vector2 initialPosition)
 Set mover at initial position. More...
 

Public Attributes

float Length = 100
 Spring length More...
 
float K = 0.2f
 K coefficient More...
 
float MinLength = 50
 Minimal length More...
 
float MaxLength = 150
 Maximal length More...
 

Detailed Description

Simple spring. Spring anchor is the node position. Manage children as targets.

Definition at line 12 of file SimpleSpring.cs.

Constructor & Destructor Documentation

◆ SimpleSpring()

Oscillation.SimpleSpring.SimpleSpring ( )
inline

Create a default spring.

Definition at line 34 of file SimpleSpring.cs.

35  {
36  lineSprite = new SimpleLineSprite() { Width = 2 };
37  }
Use this to draw a line between two points. Instead of DrawLine and Line2D, it can be batched.

Member Function Documentation

◆ SetMover()

void Oscillation.SimpleSpring.SetMover ( SimpleMover  mover,
Vector2  initialPosition 
)
inline

Set mover at initial position.

Parameters
moverMover
initialPositionInitial position

Definition at line 44 of file SimpleSpring.cs.

45  {
46  if (currentMover != null)
47  {
48  RemoveChild(currentMover);
49  currentMover.QueueFree();
50  }
51 
52  currentMover = mover;
53  AddChild(currentMover);
54 
55  // Set position
56  currentMover.Position = initialPosition;
57  }

Member Data Documentation

◆ K

float Oscillation.SimpleSpring.K = 0.2f

K coefficient

Definition at line 18 of file SimpleSpring.cs.

◆ Length

float Oscillation.SimpleSpring.Length = 100

Spring length

Definition at line 15 of file SimpleSpring.cs.

◆ MaxLength

float Oscillation.SimpleSpring.MaxLength = 150

Maximal length

Definition at line 24 of file SimpleSpring.cs.

◆ MinLength

float Oscillation.SimpleSpring.MinLength = 50

Minimal length

Definition at line 21 of file SimpleSpring.cs.


The documentation for this class was generated from the following file: