fuzzyworld

godot-shooter / commit

Remove level label from HUD, replace with pause button.

0005bbcc380687b57a40a204c347f4f4d35f77bc · Pavel Safronov · 2023-11-10 11:01:20 -0800 · parents d2a3202c3462

Remove level label from HUD, replace with pause button.
 HUD.gd   |  6 +++---
 HUD.tscn | 35 ++++++++++++++---------------------
 2 files changed, 17 insertions(+), 24 deletions(-)

diff --git a/HUD.gd b/HUD.gd
index 22586fc..8cb26eb 100644
--- a/HUD.gd
+++ b/HUD.gd
@@ -2,7 +2,6 @@ extends Control
 
 const Utils = preload("res://Utils.gd")
 export var score = 0
-export var level = 1
 export var objective = "1/17"
 signal paused
 signal debug_signal
@@ -10,12 +9,10 @@ signal debug_signal
 onready var label = $CanvasLayer/MessageLabel
 onready var animation_player = $AnimationPlayer
 onready var score_label = $HBoxContainer/Score
-onready var level_label = $MarginContainer/HBoxContainer2/Level
 onready var objective_label = $MarginContainer/HBoxContainer2/Objective
 
 func _process(_delta: float) -> void:
 	score_label.text = "%s" % score
-	level_label.text = "%s" % level
 	objective_label.text = "%s" % objective
 	if Input.is_action_just_pressed("exit"):
 		if OS.get_name() == "OSX":
@@ -54,3 +51,6 @@ func show_message(message: String, duration_seconds: int = 2) -> void:
 	
 func set_label_text(new_text: String) -> void:
 	label.text = new_text
+
+func _on_PauseButton_pressed() -> void:
+	emit_signal("paused")
diff --git a/HUD.tscn b/HUD.tscn
index 6e38069..8b9355b 100644
--- a/HUD.tscn
+++ b/HUD.tscn
@@ -61,16 +61,16 @@ margin_right = 282.0
 margin_bottom = 74.0
 
 [node name="ScoreText" type="Label" parent="HBoxContainer"]
-margin_top = 9.0
-margin_right = 143.0
-margin_bottom = 65.0
+margin_top = 7.0
+margin_right = 206.0
+margin_bottom = 66.0
 text = "Score: "
 
 [node name="Score" type="Label" parent="HBoxContainer"]
-margin_left = 151.0
-margin_top = 9.0
-margin_right = 212.0
-margin_bottom = 65.0
+margin_left = 214.0
+margin_top = 7.0
+margin_right = 313.0
+margin_bottom = 66.0
 text = "100"
 uppercase = true
 
@@ -84,22 +84,13 @@ margin_top = -74.0
 margin_right = 480.0
 margin_bottom = 74.0
 
-[node name="LevelText" type="Label" parent="MarginContainer/HBoxContainer2"]
-visible = false
-margin_top = 9.0
-margin_right = 118.0
-margin_bottom = 65.0
-text = "Level:"
-
-[node name="Level" type="Label" parent="MarginContainer/HBoxContainer2"]
-visible = false
-margin_top = 9.0
-margin_right = 13.0
-margin_bottom = 65.0
-text = "1"
+[node name="PauseButton" type="Button" parent="MarginContainer/HBoxContainer2"]
+margin_right = 52.0
+margin_bottom = 74.0
+text = "="
 
 [node name="Objective" type="Label" parent="MarginContainer/HBoxContainer2"]
-margin_left = 407.0
+margin_left = 387.0
 margin_right = 480.0
 margin_bottom = 74.0
 size_flags_horizontal = 10
@@ -127,3 +118,5 @@ autowrap = true
 [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
 "anims/message fade in" = SubResource( 2 )
 "anims/message fade out" = SubResource( 1 )
+
+[connection signal="pressed" from="MarginContainer/HBoxContainer2/PauseButton" to="." method="_on_PauseButton_pressed"]