mirror of
https://github.com/HarmonyHoney/tiny_crate.git
synced 2026-08-01 20:12:44 +00:00
options menu! (WIP)
also x+c instead of z+x controls now
This commit is contained in:
parent
215d0d326e
commit
8e2d8a8d10
7 changed files with 129 additions and 25 deletions
BIN
assets/image/hud2.png
Normal file
BIN
assets/image/hud2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 666 B |
|
|
@ -169,13 +169,13 @@ right={
|
|||
}
|
||||
jump={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":90,"unicode":0,"echo":false,"script":null)
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
action={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null)
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":67,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":2,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ extends CanvasLayer
|
|||
|
||||
var node_timer : Label
|
||||
var node_death : Label
|
||||
|
||||
var control : Control
|
||||
|
||||
func _ready():
|
||||
node_timer = $Timer/Label
|
||||
node_death = $Death
|
||||
|
||||
node_timer = $Control/Timer/Label
|
||||
node_death = $Control/Death
|
||||
control = $Control
|
||||
|
||||
func _process(delta):
|
||||
pass
|
||||
|
|
@ -16,6 +16,13 @@ func _input(event):
|
|||
if dev.is_open:
|
||||
return
|
||||
|
||||
func hide():
|
||||
control.visible = false
|
||||
|
||||
func show():
|
||||
control.visible = true
|
||||
|
||||
|
||||
|
||||
func set_time(arg):
|
||||
var _min = str(int(arg / 60))
|
||||
|
|
@ -30,3 +37,5 @@ func set_time(arg):
|
|||
#_msec = _msec.substr(1, 2)
|
||||
|
||||
node_timer.text = _min + ":" + _sec
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,23 +1,32 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://assets/font/m3x6.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://assets/image/timer.png" type="Texture" id=2]
|
||||
[ext_resource path="res://src/autoload/HUD.gd" type="Script" id=3]
|
||||
[ext_resource path="res://assets/image/hud2.png" type="Texture" id=4]
|
||||
|
||||
[node name="HUD" type="CanvasLayer"]
|
||||
pause_mode = 2
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Timer" type="TextureRect" parent="."]
|
||||
visible = false
|
||||
margin_right = 32.0
|
||||
margin_bottom = 32.0
|
||||
[node name="Control" type="Control" parent="."]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Timer" type="TextureRect" parent="Control"]
|
||||
margin_left = 9.0
|
||||
margin_top = 9.0
|
||||
margin_right = 41.0
|
||||
margin_bottom = 41.0
|
||||
texture = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="Timer"]
|
||||
[node name="Label" type="Label" parent="Control/Timer"]
|
||||
margin_left = 27.0
|
||||
margin_top = 12.0
|
||||
margin_right = 53.0
|
||||
|
|
@ -29,7 +38,7 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Death" type="Label" parent="."]
|
||||
[node name="Death" type="Label" parent="Control"]
|
||||
visible = false
|
||||
margin_left = 5.0
|
||||
margin_top = 16.0
|
||||
|
|
@ -40,3 +49,7 @@ text = "testing 123"
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="hud2" type="Sprite" parent="Control"]
|
||||
texture = ExtResource( 4 )
|
||||
centered = false
|
||||
|
|
|
|||
|
|
@ -3,19 +3,29 @@ extends CanvasLayer
|
|||
var is_paused := false
|
||||
var menu_list : Label
|
||||
var menu : Control
|
||||
var paused_menu : NinePatchRect
|
||||
var paused_list : Label
|
||||
var options_menu: NinePatchRect
|
||||
var options_list : Label
|
||||
|
||||
var cursor := 0
|
||||
var menu_items := ["resume", "options", "level select", "quit game"]
|
||||
var menu_items := []
|
||||
var selection := ""
|
||||
var paused_items := ["resume", "options", "level select", "quit game"]
|
||||
var options_items := ["back", "fullscreen", "window size", "volume"]
|
||||
|
||||
var timer := 0.1
|
||||
var clock := 0.0
|
||||
|
||||
func _ready():
|
||||
paused_menu = $Menu/Paused
|
||||
paused_list = $Menu/Paused/List
|
||||
options_menu = $Menu/Options
|
||||
options_list = $Menu/Options/List
|
||||
|
||||
menu = $Menu
|
||||
menu.visible = false
|
||||
menu_list = $Menu/NinePatchRect/List
|
||||
|
||||
menu_list = paused_list
|
||||
|
||||
func _process(delta):
|
||||
if clock != 0:
|
||||
|
|
@ -48,10 +58,9 @@ func toggle_pause():
|
|||
|
||||
if is_paused:
|
||||
get_tree().paused = is_paused
|
||||
cursor = 0
|
||||
write_menu()
|
||||
switch_menu("paused")
|
||||
else:
|
||||
pass
|
||||
options_menu.visible = false
|
||||
|
||||
|
||||
func write_menu():
|
||||
|
|
@ -66,10 +75,30 @@ func menu_select():
|
|||
"resume":
|
||||
toggle_pause()
|
||||
"options":
|
||||
pass
|
||||
switch_menu("options")
|
||||
"level select":
|
||||
get_tree().change_scene("res://src/menu/MapSelect.tscn")
|
||||
toggle_pause()
|
||||
"quit game":
|
||||
get_tree().quit()
|
||||
"back":
|
||||
switch_menu("paused")
|
||||
"fullscreen":
|
||||
OS.window_fullscreen = !OS.window_fullscreen
|
||||
"volume":
|
||||
pass
|
||||
|
||||
func switch_menu(arg):
|
||||
cursor = 0
|
||||
match arg:
|
||||
"paused":
|
||||
paused_menu.visible = true
|
||||
options_menu.visible = false
|
||||
menu_list = paused_list
|
||||
menu_items = paused_items
|
||||
"options":
|
||||
paused_menu.visible = false
|
||||
options_menu.visible = true
|
||||
menu_list = options_list
|
||||
menu_items = options_items
|
||||
write_menu()
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="NinePatchRect" type="NinePatchRect" parent="Menu"]
|
||||
[node name="Paused" type="NinePatchRect" parent="Menu"]
|
||||
margin_left = -36.0
|
||||
margin_top = -36.0
|
||||
margin_right = 36.0
|
||||
|
|
@ -34,7 +34,7 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Header" type="Label" parent="Menu/NinePatchRect"]
|
||||
[node name="Header" type="Label" parent="Menu/Paused"]
|
||||
margin_top = 4.0
|
||||
margin_right = 72.0
|
||||
margin_bottom = 23.0
|
||||
|
|
@ -46,7 +46,7 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="List" type="Label" parent="Menu/NinePatchRect"]
|
||||
[node name="List" type="Label" parent="Menu/Paused"]
|
||||
margin_left = 8.0
|
||||
margin_top = 16.0
|
||||
margin_right = 56.0
|
||||
|
|
@ -60,3 +60,50 @@ quit game"
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Options" type="NinePatchRect" parent="Menu"]
|
||||
visible = false
|
||||
margin_left = -36.0
|
||||
margin_top = -36.0
|
||||
margin_right = 36.0
|
||||
margin_bottom = 36.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
rect_min_size = Vector2( 120, 88 )
|
||||
texture = ExtResource( 2 )
|
||||
patch_margin_left = 8
|
||||
patch_margin_top = 8
|
||||
patch_margin_right = 8
|
||||
patch_margin_bottom = 8
|
||||
axis_stretch_horizontal = 1
|
||||
axis_stretch_vertical = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Header" type="Label" parent="Menu/Options"]
|
||||
margin_top = 4.0
|
||||
margin_right = 120.0
|
||||
margin_bottom = 23.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
custom_colors/font_color = Color( 1, 0.639216, 0, 1 )
|
||||
text = "-OPTIONS-"
|
||||
align = 1
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="List" type="Label" parent="Menu/Options"]
|
||||
margin_left = 8.0
|
||||
margin_top = 16.0
|
||||
margin_right = 56.0
|
||||
margin_bottom = 57.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
custom_colors/font_color = Color( 1, 0.945098, 0.909804, 1 )
|
||||
text = "back
|
||||
fullscreen
|
||||
volume
|
||||
"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ func _ready():
|
|||
label_list.text = map_list
|
||||
|
||||
scroll()
|
||||
|
||||
HUD.hide()
|
||||
|
||||
func _process(delta):
|
||||
var btny = btn.p("down") - btn.p("up")
|
||||
|
|
@ -41,8 +43,12 @@ func _process(delta):
|
|||
scroll(btny)
|
||||
|
||||
if btn.p("jump"):
|
||||
Shared.map_name = maps[cursor]
|
||||
get_tree().change_scene(map_path + maps[cursor] + ".tscn")
|
||||
select()
|
||||
|
||||
func select():
|
||||
Shared.map_name = maps[cursor]
|
||||
get_tree().change_scene(map_path + maps[cursor] + ".tscn")
|
||||
HUD.show()
|
||||
|
||||
|
||||
func scroll(arg = 0):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue