-
Notifications
You must be signed in to change notification settings - Fork 0
/
Menu.gd
59 lines (43 loc) · 1.59 KB
/
Menu.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
55
56
57
58
59
extends Control
var ui_up_down_path: String = "res://assets/ui-up-down2.mp3"
var ui_accept_path: String = "res://assets/swhit.ogg"
# Called when the node enters the scene tree for the first time.
func _ready():
$VBoxContainer/StartButton.grab_focus()
var sfx_ui_up_down: Resource = load(ui_up_down_path)
$UIAudio.stream = sfx_ui_up_down
$BackgroundAudio.play()
GlobalVariables.points = 0
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
func _input(event):
if event is InputEventMouseMotion:
$VBoxContainer/StartButton.release_focus()
$VBoxContainer/ControlsButton.release_focus()
$VBoxContainer/QuitButton.release_focus()
elif (
(Input.is_action_pressed("ui_down") or Input.is_action_pressed("ui_up"))
and no_button_has_focus()
):
$VBoxContainer/QuitButton.grab_focus()
if(Input.is_action_pressed("ui_down") or Input.is_action_pressed("ui_up")):
$UIAudio.play()
elif Input.is_action_just_pressed("ui_accept"):
var sfx_accept: Resource = load(ui_accept_path)
$UIAudio.stream = sfx_accept
$UIAudio.play()
func no_button_has_focus() -> bool:
return (
not $VBoxContainer/StartButton.has_focus()
and not $VBoxContainer/ControlsButton.has_focus()
and not $VBoxContainer/QuitButton.has_focus()
)
func _on_StartButton_pressed():
get_tree().change_scene("res://Gnop/GnopMain.tscn")
func _on_ControlsButton_pressed():
get_tree().change_scene("res://Controls.tscn")
#var options = load('res://scene_path.tscn').instance()
#get_tree().current_scene.add_child(options)
func _on_QuitButton_pressed():
get_tree().quit()