1
Fork 0
mirror of https://github.com/Steffo99/looping-for-loops.git synced 2024-11-22 08:04:23 +00:00

🐞 Fix ScrollParents not properly inheriting movement speed

This commit is contained in:
Steffo 2020-10-04 17:48:28 +02:00
parent f8f935a99a
commit c8342b9e1c
4 changed files with 6 additions and 7 deletions

View file

@ -8,9 +8,6 @@ export(bool) var randomize_gear_starting_position: bool = false
signal cb_speed_changed(old, new) signal cb_speed_changed(old, new)
func _ready():
set_cb_speed(cb_speed)
func set_cb_speed(value): func set_cb_speed(value):
var old = cb_speed var old = cb_speed
cb_speed = value cb_speed = value

View file

@ -20,6 +20,7 @@ __meta__ = {
[node name="ConveyorBelt" parent="." instance=ExtResource( 3 )] [node name="ConveyorBelt" parent="." instance=ExtResource( 3 )]
position = Vector2( 640, 700 ) position = Vector2( 640, 700 )
cb_speed = 100.0
[node name="Player" parent="." instance=ExtResource( 1 )] [node name="Player" parent="." instance=ExtResource( 1 )]
position = Vector2( 340, 500 ) position = Vector2( 340, 500 )

View file

@ -2,12 +2,13 @@ extends ScrollParent
class_name ConveyorScrollParent 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") 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") conveyor_belt.connect("cb_speed_changed", self, "_on_ConveyorBelt_cb_speed_changed")
func _on_ConveyorBelt_cb_speed_changed(old, new): func _on_ConveyorBelt_cb_speed_changed(old, new):
scroll_velocity.x = -conveyor_belt.get_relative_cb_speed(parent.position) scroll_velocity.x = -new

View file

@ -2,7 +2,7 @@ extends Node
class_name ScrollParent class_name ScrollParent
export(Vector2) var scroll_velocity: Vector2 = Vector2(-100, 0) export(Vector2) var scroll_velocity: Vector2 = Vector2(0, 0)
var parent = null var parent = null