StartButton.gd 510 B

1234567891011121314151617181920212223242526
  1. class_name StartButton
  2. extends Button
  3. export (Array, PackedScene) var scenes
  4. var _selected_scene: PackedScene
  5. func select(index: int) -> void:
  6. assert(index >= 0, "Index must be positive")
  7. assert(index < scenes.size(), "Index must be within bounds")
  8. _selected_scene = scenes[index]
  9. func run_selected_scene():
  10. var err := get_tree().change_scene_to(_selected_scene)
  11. assert(err == OK)
  12. func _on_lab_selected(index: int) -> void:
  13. select(index)
  14. func _on_self_pressed() -> void:
  15. run_selected_scene()