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

Simple static lines. Can be used to draw physics outlines. More...

Inherits StaticBody2D.

Inherited by Examples.Chapter5.C5Exercise3.WaveWall.

Public Member Functions

 SimpleStaticLines ()
 Create empty outline. More...
 
void AddSegment (Vector2 start, Vector2 end)
 Add a line segment. More...
 

Public Attributes

Color BaseColor = Colors.LightGoldenrod
 Color More...
 

Detailed Description

Simple static lines. Can be used to draw physics outlines.

Definition at line 11 of file SimpleStaticChain.cs.

Constructor & Destructor Documentation

◆ SimpleStaticLines()

Physics.SimpleStaticLines.SimpleStaticLines ( )
inline

Create empty outline.

Definition at line 23 of file SimpleStaticChain.cs.

24  {
25  shapes = new List<CollisionShape2D>();
26  segments = new List<SegmentShape2D>();
27  lineSprites = new List<SimpleLineSprite>();
28  }

Member Function Documentation

◆ AddSegment()

void Physics.SimpleStaticLines.AddSegment ( Vector2  start,
Vector2  end 
)
inline

Add a line segment.

Parameters
startStart position
endEnd position

Definition at line 35 of file SimpleStaticChain.cs.

36  {
37  var segment = new SegmentShape2D()
38  {
39  A = start,
40  B = end
41  };
42  var shape = new CollisionShape2D() { Shape = segment };
43 
44  segments.Add(segment);
45  shapes.Add(shape);
46  AddChild(shape);
47 
48  var lineSprite = new SimpleLineSprite()
49  {
50  PositionA = GlobalPosition + segment.A,
51  PositionB = GlobalPosition + segment.B,
52  Modulate = BaseColor,
53  Width = 2
54  };
55  lineSprites.Add(lineSprite);
56  AddChild(lineSprite);
57  }
Use this to draw a line between two points. Instead of DrawLine and Line2D, it can be batched.

Member Data Documentation

◆ BaseColor

Color Physics.SimpleStaticLines.BaseColor = Colors.LightGoldenrod

Color

Definition at line 14 of file SimpleStaticChain.cs.


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