added basic scene manager
This commit is contained in:
parent
f694d5c4f8
commit
2cf0846597
7 changed files with 37 additions and 57 deletions
22
globals/scene_manager.gd
Normal file
22
globals/scene_manager.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
extends Node
|
||||
|
||||
@onready var scene_root = $/root/Game/CurrentScene
|
||||
var current_world : Node = null
|
||||
|
||||
func set_world(path: String):
|
||||
if ResourceLoader.exists(path):
|
||||
var world = load(path).instantiate()
|
||||
scene_root.add_child(world)
|
||||
current_world = world
|
||||
else:
|
||||
printerr("Level %s does not exist" % path)
|
||||
|
||||
func remove_world():
|
||||
var world = scene_root.get_child(0)
|
||||
if world == null:
|
||||
printerr("No world node found")
|
||||
return
|
||||
|
||||
scene_root.remove_child(world)
|
||||
world.queue_free()
|
||||
current_world = null
|
||||
Loading…
Add table
Add a link
Reference in a new issue