From a083e6a1da04bbbf7b6340ff30b1c2d96b665237 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Thu, 24 Sep 2020 10:31:41 +0200 Subject: [PATCH] Set center of gravity correctly when shrinking Nodes Control --- arrow.gd | 2 +- arrow.tscn | 8 ++++---- repository.gd | 3 ++- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/arrow.gd b/arrow.gd index 61c5a48..457e262 100644 --- a/arrow.gd +++ b/arrow.gd @@ -15,7 +15,7 @@ func _process(_delta): position = Vector2(0,0) var start = repository.objects[source].position - var end = start + Vector2(0, 30) + var end = start + Vector2(0, 60) if repository and repository.objects.has(target) and repository.objects[target].visible: var t = repository.objects[target] diff --git a/arrow.tscn b/arrow.tscn index 8399df8..2550926 100644 --- a/arrow.tscn +++ b/arrow.tscn @@ -47,10 +47,10 @@ __meta__ = { } [node name="Target" type="Label" parent="."] -margin_left = -229.024 -margin_top = 63.3118 -margin_right = 232.976 -margin_bottom = 89.3118 +margin_left = -230.84 +margin_top = 42.1225 +margin_right = 231.16 +margin_bottom = 68.1225 custom_fonts/font = ExtResource( 2 ) custom_colors/font_color = Color( 0.356863, 0.356863, 0.356863, 1 ) text = "label" diff --git a/repository.gd b/repository.gd index 3773985..b499b64 100644 --- a/repository.gd +++ b/repository.gd @@ -142,7 +142,8 @@ func apply_forces(): var f = 2000/pow(d+0.00001,1.5) o.position += dir*f o2.position -= dir*f - var center_of_gravity = rect_size/2 + var center_of_gravity = nodes.rect_size/2 + print(center_of_gravity) var d = o.position.distance_to(center_of_gravity) var dir = (o.position - center_of_gravity).normalized() var f = (d+0.00001)*Vector2(0.03, 0.01)