summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/CameraTrackFollower.gd10
-rw-r--r--scenes/levels/base_level.gd14
-rw-r--r--scenes/levels/typeracer.gd1
3 files changed, 20 insertions, 5 deletions
diff --git a/components/CameraTrackFollower.gd b/components/CameraTrackFollower.gd
index 819e13b..e2d9bbe 100644
--- a/components/CameraTrackFollower.gd
+++ b/components/CameraTrackFollower.gd
@@ -7,9 +7,13 @@ signal done()
var _points
func _path(value):
path = value
- _pidx = 0
- _t = 0
- _points = value.curve.get_baked_points()
+ if path == null:
+ _points = []
+ _pidx = -1
+ else:
+ _pidx = 0
+ _t = 0
+ _points = value.curve.get_baked_points()
current_speed = 0
_done_emitted = false
print("New path set to CameraTrackFollower")
diff --git a/scenes/levels/base_level.gd b/scenes/levels/base_level.gd
index df08a32..dc344e2 100644
--- a/scenes/levels/base_level.gd
+++ b/scenes/levels/base_level.gd
@@ -57,8 +57,17 @@ func _load_next_level():
_load_current_level()
func _unload_current_level():
- pass
-
+ _path_renderer.path = null
+ _camera.path = null
+ _loaded_level = null
+ for c in _level_holder.get_children():
+ _delayed_delete(c)
+ _track.queue_free()
+ yield(get_tree(), "idle_frame") # todo animation here? post mortem
+
+func _delayed_delete(c):
+ yield(get_tree().create_timer(2.0), "timeout")
+ c.queue_free()
func _load_current_level():
if _loaded_level != null:
push_error("Tried to load level, while another level was already loaded.")
@@ -83,6 +92,7 @@ func _on_MenuButton_on_click():
func _on_Camera2D_done():
print("Camera movement done")
+ _last_camera_location = $Camera2D.position
_loaded_level.start()
func _disable_input(node):
diff --git a/scenes/levels/typeracer.gd b/scenes/levels/typeracer.gd
index 95b8cd2..536e35a 100644
--- a/scenes/levels/typeracer.gd
+++ b/scenes/levels/typeracer.gd
@@ -2,4 +2,5 @@ extends Level
func start():
.start()
+ finish_level() # fix your stuff
pass