From c8342b9e1cd4c2115e6bb873d74800eb2f57684e Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 4 Oct 2020 17:48:28 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20Fix=20ScrollParents=20not=20prop?= =?UTF-8?q?erly=20inheriting=20movement=20speed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Objects/ConveyorBelt/ConveyorBelt.gd | 3 --- Objects/Main.tscn | 1 + Objects/ScrollingObjects/Utilities/ConveyorScrollParent.gd | 7 ++++--- Objects/ScrollingObjects/Utilities/ScrollParent.gd | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Objects/ConveyorBelt/ConveyorBelt.gd b/Objects/ConveyorBelt/ConveyorBelt.gd index 0d48cdf..92eea7a 100644 --- a/Objects/ConveyorBelt/ConveyorBelt.gd +++ b/Objects/ConveyorBelt/ConveyorBelt.gd @@ -8,9 +8,6 @@ export(bool) var randomize_gear_starting_position: bool = false signal cb_speed_changed(old, new) -func _ready(): - set_cb_speed(cb_speed) - func set_cb_speed(value): var old = cb_speed cb_speed = value diff --git a/Objects/Main.tscn b/Objects/Main.tscn index b8c774e..33b1b94 100644 --- a/Objects/Main.tscn +++ b/Objects/Main.tscn @@ -20,6 +20,7 @@ __meta__ = { [node name="ConveyorBelt" parent="." instance=ExtResource( 3 )] position = Vector2( 640, 700 ) +cb_speed = 100.0 [node name="Player" parent="." instance=ExtResource( 1 )] position = Vector2( 340, 500 ) diff --git a/Objects/ScrollingObjects/Utilities/ConveyorScrollParent.gd b/Objects/ScrollingObjects/Utilities/ConveyorScrollParent.gd index de843ed..d6f3c9c 100644 --- a/Objects/ScrollingObjects/Utilities/ConveyorScrollParent.gd +++ b/Objects/ScrollingObjects/Utilities/ConveyorScrollParent.gd @@ -2,12 +2,13 @@ extends ScrollParent class_name ConveyorScrollParent -onready var conveyor_belt: ConveyorBelt = null +var conveyor_belt: ConveyorBelt = null -func _enter_tree(): +func _ready(): conveyor_belt = get_tree().current_scene.get_node("ConveyorBelt") + _on_ConveyorBelt_cb_speed_changed(0, conveyor_belt.cb_speed) conveyor_belt.connect("cb_speed_changed", self, "_on_ConveyorBelt_cb_speed_changed") func _on_ConveyorBelt_cb_speed_changed(old, new): - scroll_velocity.x = -conveyor_belt.get_relative_cb_speed(parent.position) + scroll_velocity.x = -new diff --git a/Objects/ScrollingObjects/Utilities/ScrollParent.gd b/Objects/ScrollingObjects/Utilities/ScrollParent.gd index dfb4171..786b389 100644 --- a/Objects/ScrollingObjects/Utilities/ScrollParent.gd +++ b/Objects/ScrollingObjects/Utilities/ScrollParent.gd @@ -2,7 +2,7 @@ extends Node class_name ScrollParent -export(Vector2) var scroll_velocity: Vector2 = Vector2(-100, 0) +export(Vector2) var scroll_velocity: Vector2 = Vector2(0, 0) var parent = null