|
123456789101112131415161718192021222324252627 |
- extends Node
-
- export var scenes : Dictionary
-
- signal end
-
- func _ready():
- $YarnRunnerNode.yarnRunner.add_command("Scene", funcref(self, "load_scene"))
- $YarnRunnerNode.yarnRunner.add_command("WaitSignal", funcref(self, "wait_signal"))
- yield($YarnRunnerNode.start_script(), "completed")
-
- func load_scene(args):
- yield(get_tree(),"idle_frame")
- if args.size() > 0:
- var scene_key = args[0]
- if scenes.has(scene_key):
- for child in $SceneContainer.get_children():
- child.queue_free()
- var scene = scenes[scene_key].instance()
- $SceneContainer.add_child(scene)
-
- func wait_signal(args):
- yield(self, "end")
-
- func _input(event):
- if event.is_action_pressed("ui_cancel"):
- emit_signal("end")
|