Added a pause menu with options to continue or quit.
This commit is contained in:
parent
5893123adb
commit
f87278323d
@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://dchj6g2i8ebph"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://dchj6g2i8ebph"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bpxggc8nr6tf6" path="res://scenes/player.gd" id="1_muv8p"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5of6aaxop1hl" path="res://scenes/block.tscn" id="2_tc7dm"]
|
||||
[ext_resource type="Script" uid="uid://b7fopt7sx74g8" path="res://scenes/Levels/menu.gd" id="3_tc7dm"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_2q6dc"]
|
||||
bounce = 0.5
|
||||
@ -69,3 +70,43 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.298158, -7.0724635)
|
||||
|
||||
[node name="Block2" parent="Starter Blocks" instance=ExtResource("2_tc7dm")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.63255787, 2.596316, -6.980046)
|
||||
|
||||
[node name="Menu" type="CanvasLayer" parent="."]
|
||||
process_mode = 3
|
||||
visible = false
|
||||
script = ExtResource("3_tc7dm")
|
||||
|
||||
[node name="Control" type="Control" parent="Menu"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Menu/Control"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -39.5
|
||||
offset_top = -33.0
|
||||
offset_right = 39.5
|
||||
offset_bottom = 33.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="ContinueButton" type="Button" parent="Menu/Control/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Continue"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="Menu/Control/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Quit"
|
||||
|
||||
[connection signal="pressed" from="Menu/Control/VBoxContainer/ContinueButton" to="Menu" method="_on_continue_button_pressed"]
|
||||
[connection signal="pressed" from="Menu/Control/VBoxContainer/QuitButton" to="Menu" method="_on_quit_button_pressed"]
|
||||
|
||||
24
scenes/Levels/menu.gd
Normal file
24
scenes/Levels/menu.gd
Normal file
@ -0,0 +1,24 @@
|
||||
extends CanvasLayer
|
||||
|
||||
@onready var pause_menu = $Control
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("ui_cancel"):
|
||||
if get_tree().paused:
|
||||
resume_game()
|
||||
else:
|
||||
pause_game()
|
||||
|
||||
func pause_game():
|
||||
get_tree().paused = true
|
||||
visible = true
|
||||
|
||||
func resume_game():
|
||||
get_tree().paused = false
|
||||
visible = false
|
||||
|
||||
func _on_quit_button_pressed():
|
||||
get_tree().quit()
|
||||
|
||||
func _on_continue_button_pressed():
|
||||
resume_game()
|
||||
1
scenes/Levels/menu.gd.uid
Normal file
1
scenes/Levels/menu.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b7fopt7sx74g8
|
||||
@ -1,4 +1,7 @@
|
||||
extends RigidBody3D
|
||||
# Initially I used a CharacterBody3D, however, I wanted the player to bounce off
|
||||
# other objects in the environment and that would have required manual handling
|
||||
# of collisions. So that's why we're using a RigidBody3D instead.
|
||||
|
||||
const MOVE_SPEED := 8.0
|
||||
const ACCELLERATION := 30.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user