Added pause menu
This commit is contained in:
@@ -1,2 +1,15 @@
|
||||
class_name AbstractLevel
|
||||
extends Node2D
|
||||
|
||||
|
||||
@onready var pause_menu : PauseMenu = $%PauseMenu
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
pause_menu.hide()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("pause"):
|
||||
get_tree().paused = true
|
||||
pause_menu.show()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=13 format=3 uid="uid://mpsu4g2b5h3a"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://mpsu4g2b5h3a"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c737mx0kxva7i" path="res://game/levels/abstract_level.gd" id="1_o2mui"]
|
||||
[ext_resource type="PackedScene" uid="uid://dtcad8tdx78tg" path="res://game/characters/player.tscn" id="2_r0ht6"]
|
||||
@@ -6,6 +6,7 @@
|
||||
[ext_resource type="Material" uid="uid://dojhoc6ljpt1a" path="res://game/materials/gray_walls.tres" id="3_pi5fd"]
|
||||
[ext_resource type="Material" uid="uid://d2o2o1w8kb51g" path="res://game/materials/white_walls.tres" id="5_6b8cu"]
|
||||
[ext_resource type="Material" uid="uid://bhksbugqhxxa0" path="res://game/materials/black_walls.tres" id="6_x8k35"]
|
||||
[ext_resource type="PackedScene" uid="uid://dsts4y32slhnc" path="res://game/menu/pause_menu.tscn" id="7_l0xih"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_pi5fd"]
|
||||
texture = ExtResource("3_fnnmn")
|
||||
@@ -381,3 +382,8 @@ tile_set = SubResource("TileSet_b7vts")
|
||||
[node name="WhiteWalls" type="TileMapLayer" parent="Tiles"]
|
||||
material = ExtResource("5_6b8cu")
|
||||
tile_set = SubResource("TileSet_l0xih")
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="PauseMenu" parent="CanvasLayer" instance=ExtResource("7_l0xih")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
class_name PauseMenu
|
||||
extends Control
|
||||
|
||||
|
||||
@onready var continue_button : Button = $%ContinueButton
|
||||
@onready var main_menu_button : Button = $%MainMenuButton
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_init_focus()
|
||||
_setup_neighbors()
|
||||
|
||||
|
||||
func _init_focus() -> void:
|
||||
continue_button.grab_focus()
|
||||
|
||||
|
||||
func _setup_neighbors() -> void:
|
||||
continue_button.focus_neighbor_top = main_menu_button.get_path()
|
||||
main_menu_button.focus_neighbor_bottom = continue_button.get_path()
|
||||
|
||||
|
||||
func _on_continue_button_pressed() -> void:
|
||||
get_tree().paused = false
|
||||
hide()
|
||||
|
||||
|
||||
func _on_main_menu_button_pressed() -> void:
|
||||
get_tree().paused = false
|
||||
get_tree().change_scene_to_file("res://game/menu/main_menu.tscn")
|
||||
|
||||
|
||||
func _on_visibility_changed() -> void:
|
||||
if visible:
|
||||
if continue_button != null:
|
||||
continue_button.grab_focus()
|
||||
@@ -0,0 +1 @@
|
||||
uid://cvw5egmj1f62u
|
||||
@@ -0,0 +1,51 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dsts4y32slhnc"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bh56my8b2htnr" path="res://themes/menu.tres" id="1_i4rg2"]
|
||||
[ext_resource type="Script" uid="uid://cvw5egmj1f62u" path="res://game/menu/pause_menu.gd" id="2_e1jsn"]
|
||||
|
||||
[node name="PauseMenu" type="Control"]
|
||||
process_mode = 2
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("1_i4rg2")
|
||||
script = ExtResource("2_e1jsn")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
|
||||
[node name="ContinueButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Continue"
|
||||
|
||||
[node name="MainMenuButton" type="Button" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Main menu"
|
||||
|
||||
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/ContinueButton" to="." method="_on_continue_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer/VBoxContainer/MainMenuButton" to="." method="_on_main_menu_button_pressed"]
|
||||
+2
-1
@@ -10,7 +10,7 @@ config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="OneBitGameJam8"
|
||||
config/name="Cult Manor"
|
||||
run/main_scene="uid://c4iica45gnke0"
|
||||
config/features=PackedStringArray("4.5", "GL Compatibility")
|
||||
boot_splash/bg_color=Color(0, 0, 0, 1)
|
||||
@@ -159,3 +159,4 @@ pause={
|
||||
textures/canvas_textures/default_texture_filter=0
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
environment/defaults/default_clear_color=Color(0, 0, 0, 1)
|
||||
|
||||
Reference in New Issue
Block a user