You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 4 година
123456789101112131415161718192021222324252627
  1. extends Node
  2. export var scenes : Dictionary
  3. signal end
  4. func _ready():
  5. $YarnRunnerNode.yarnRunner.add_command("Scene", funcref(self, "load_scene"))
  6. $YarnRunnerNode.yarnRunner.add_command("WaitSignal", funcref(self, "wait_signal"))
  7. yield($YarnRunnerNode.start_script(), "completed")
  8. func load_scene(args):
  9. yield(get_tree(),"idle_frame")
  10. if args.size() > 0:
  11. var scene_key = args[0]
  12. if scenes.has(scene_key):
  13. for child in $SceneContainer.get_children():
  14. child.queue_free()
  15. var scene = scenes[scene_key].instance()
  16. $SceneContainer.add_child(scene)
  17. func wait_signal(args):
  18. yield(self, "end")
  19. func _input(event):
  20. if event.is_action_pressed("ui_cancel"):
  21. emit_signal("end")