summaryrefslogtreecommitdiffstats
path: root/root.gd
blob: dcb753d71aaa80f7732440d27467eb619bb53c05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class_name Root
extends Node2D

@export var initial_level: PackedScene

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	var level = initial_level.instantiate()
	add_child(level)

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
	pass

func change_level(level_name: String):
	var level = ResourceLoader.load("res://level_" + level_name + ".tscn")
	var current_level = get_child(0)
	remove_child(current_level)
	
	var next_level = level.instantiate()
	add_child(next_level)