pause_menu.gd 916 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. extends Control
  2. @onready var tree = get_tree()
  3. @onready var crosshair = $Crosshair
  4. @onready var pause = $Pause
  5. @onready var options = $Options
  6. @onready var voxel_world = $"../VoxelWorld"
  7. func _process(_delta):
  8. if Input.is_action_just_pressed(&"pause"):
  9. pause.visible = crosshair.visible
  10. crosshair.visible = not crosshair.visible
  11. options.visible = false
  12. if crosshair.visible:
  13. Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
  14. else:
  15. Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
  16. func _on_Resume_pressed():
  17. Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
  18. crosshair.visible = true
  19. pause.visible = false
  20. func _on_Options_pressed():
  21. options.prev_menu = pause
  22. options.visible = true
  23. pause.visible = false
  24. func _on_MainMenu_pressed():
  25. voxel_world.clean_up()
  26. tree.change_scene_to_packed(load("res://menu/main/main_menu.tscn"))
  27. func _on_Exit_pressed():
  28. voxel_world.clean_up()
  29. tree.quit()