-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhud.gd
93 lines (69 loc) · 1.59 KB
/
hud.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
extends CanvasLayer
signal start_game
signal move_up
signal move_down
signal move_left
signal move_right
signal stop_vertical
signal stop_horizontal
func update_score(value):
$MarginContainer/Score.text = str(value)
func update_timer(value):
$MarginContainer/Time.text = str(value)
func show_message(text):
$Message.text = text
$Message.show()
$Timer.start()
func _on_timer_timeout():
$Message.hide()
func _on_start_button_pressed():
$StartButton.hide()
show_touch_controls()
$Message.hide()
start_game.emit()
func show_game_over():
show_message("Game Over")
await $Timer.timeout
$StartButton.show()
hide_touch_controls()
$Message.text = "Coin Dash!"
$Message.show()
func hide_touch_controls():
$B_Up.hide()
$B_Down.hide()
$B_Right.hide()
$B_Left.hide()
func show_touch_controls():
$B_Up.modulate.a = 0.5 # 50% transparencia
$B_Down.modulate.a = 0.5
$B_Right.modulate.a = 0.5
$B_Left.modulate.a = 0.5
$B_Up.show()
$B_Down.show()
$B_Right.show()
$B_Left.show()
# "ui_left", "ui_right", "ui_up", "ui_down"
func _on_b_up_pressed():
print("Up pressed")
move_up.emit()
func _on_b_down_pressed():
print("Down pressed")
move_down.emit()
func _on_b_right_pressed():
print("Right pressed")
move_right.emit()
func _on_b_left_pressed():
print("Left pressed")
move_left.emit()
func _on_b_up_released():
print("Up released")
stop_vertical.emit()
func _on_b_down_released():
print("Down released")
stop_vertical.emit()
func _on_b_right_released():
print("Right released")
stop_horizontal.emit()
func _on_b_left_released():
print("Left released")
stop_horizontal.emit()