-
Notifications
You must be signed in to change notification settings - Fork 15
/
mainmenu.gd
54 lines (47 loc) · 1.44 KB
/
mainmenu.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
extends CanvasLayer
func _input(_event: InputEvent) -> void:
# If the player presses ESC in the main menu, it hides any current windows showing and
# shows the main menu options open.
if Input.is_action_just_pressed("ui_cancel"):
hide()
if not $Control.visible\
and not Global.Playing:
$Control.visible = true
$SelectAudio.play()
# When you press play,
func _on_Play_pressed() -> void:
$SelectAudio.play()
# it hides all windows opened
hide()
Global.Playing = true
# and grabs the player node's camera to set as the current camera.
Global.player.get_node("Head/Camera").set_current(true)
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
# We then hide the menu and logo,
$Control.visible = false
Global.player.get_node("Crosshair").visible = true
if Global.player.SprintMeter:
Global.player.get_node("Sprint").visible = true
# When you press quit, it quits the game.
func _on_Quit_pressed() -> void:
$SelectAudio.play()
get_tree().quit()
# When you press settings,
func _on_Settings_pressed() -> void:
$SelectAudio.play()
# it hides all windows opened,
hide()
# it shows the settings node,
Global.Settings.visible = true
# and hides the menu options.
$Control.visible = false
# Same thing with the credits.
func Credits() -> void:
$SelectAudio.play()
hide()
$Credits.visible = true
$Control.visible = false
# This function hides the Settings and Credits.
func hide():
Global.Settings.visible = false
$Credits.visible = false