diff options
Diffstat (limited to 'src/helpers/clouds_move.gd')
-rw-r--r-- | src/helpers/clouds_move.gd | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/helpers/clouds_move.gd b/src/helpers/clouds_move.gd new file mode 100644 index 0000000..3c26fa2 --- /dev/null +++ b/src/helpers/clouds_move.gd @@ -0,0 +1,14 @@ +extends ParallaxLayer + +export var speed := 20.0 +var offset_x = 0.0 +var last_camera_x = 0.0 + +func _ready(): + last_camera_x = get_node("../../Camera2D").get_camera_position().x + +func _process(delta): + motion_offset = Vector2(offset_x, 0) + var new_camera_x = get_node("../../Camera2D").get_camera_position().x + offset_x -= delta*speed + (new_camera_x - last_camera_x)*-2 + last_camera_x = new_camera_x |