feat: Implement touch controls and a settings menu.

This commit is contained in:
Yogi Wiguna
2026-03-24 11:11:14 +08:00
parent 878e331b6e
commit 82fdbf91d1
10 changed files with 121 additions and 145 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 12 KiB

@@ -2,21 +2,20 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://3up2su2e0lfa"
path.s3tc="res://.godot/imported/freeze_area.png-637e16813f4e334856ce1077dd0a8f60.s3tc.ctex"
uid="uid://dcwdbeqla0ooi"
path="res://.godot/imported/freeze_area.png-637e16813f4e334856ce1077dd0a8f60.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/touch_control/freeze_area.png"
dest_files=["res://.godot/imported/freeze_area.png-637e16813f4e334856ce1077dd0a8f60.s3tc.ctex"]
dest_files=["res://.godot/imported/freeze_area.png-637e16813f4e334856ce1077dd0a8f60.ctex"]
[params]
compress/mode=2
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

+39 -45
View File
@@ -19,8 +19,7 @@
[ext_resource type="Texture2D" uid="uid://pwxo4lb87yi" path="res://assets/graphics/touch_control/put_tile.png" id="26_5q0nq"]
[ext_resource type="Texture2D" uid="uid://umw3e8nfe3vr" path="res://assets/graphics/touch_control/attack_mode.png" id="27_dgi5k"]
[ext_resource type="Texture2D" uid="uid://cupfmb5m15kmf" path="res://assets/graphics/touch_control/wall.png" id="27_yq6so"]
[ext_resource type="Texture2D" uid="uid://3up2su2e0lfa" path="res://assets/graphics/touch_control/freeze_area.png" id="28_fv21b"]
[ext_resource type="Texture2D" uid="uid://ckhdyxnho6sjp" path="res://assets/graphics/touch_control/spawn_tile.png" id="28_j8jky"]
[ext_resource type="Texture2D" uid="uid://dcwdbeqla0ooi" path="res://assets/graphics/touch_control/freeze_area.png" id="28_fv21b"]
[ext_resource type="Texture2D" uid="uid://b2vhatfmufn3d" path="res://assets/graphics/touch_control/ghost.png" id="33_5q0nq"]
[ext_resource type="Texture2D" uid="uid://biun2yvglxgij" path="res://assets/graphics/touch_control/grab_tekton.png" id="36_pibwh"]
[ext_resource type="Script" uid="uid://86ikh0wuqk7v" path="res://scripts/ui/powerup_inventory_ui.gd" id="powerup_ui_script"]
@@ -1397,6 +1396,17 @@ theme_override_font_sizes/font_size = 28
text = "3:00"
horizontal_alignment = 1
[node name="SettingsBtn" type="Button" parent="." unique_id=1964422444]
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -78.0
offset_top = 8.0
offset_right = -30.0
offset_bottom = 56.0
grow_horizontal = 0
text = "⚙"
[node name="TouchControls" type="CanvasLayer" parent="." unique_id=1390485948]
script = ExtResource("touch_manager")
@@ -1423,27 +1433,15 @@ offset_bottom = -120.0
grow_vertical = 0
script = ExtResource("virtual_joystick")
[node name="ActionsBtn" type="VBoxContainer" parent="TouchControls/TouchControls" unique_id=278736451]
[node name="PowerBarBtn" type="VBoxContainer" parent="TouchControls/TouchControls" unique_id=278736451]
layout_mode = 0
offset_left = 48.000004
offset_top = 82.00001
offset_right = 114.71878
offset_bottom = 350.68915
offset_left = 47.858246
offset_top = 98.014656
offset_right = 129.85825
offset_bottom = 265.01465
rotation = -0.10297442
theme_override_constants/separation = 15
[node name="PutBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=1027790362]
visible = false
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
focus_mode = 0
icon = ExtResource("26_5q0nq")
flat = true
icon_alignment = 1
expand_icon = true
[node name="AttackModeBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=1380511463]
[node name="AttackModeBtn" type="Button" parent="TouchControls/TouchControls/PowerBarBtn" unique_id=1380511463]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
@@ -1453,16 +1451,7 @@ flat = true
icon_alignment = 1
expand_icon = true
[node name="SpawnBoostBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=1566173505]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
icon = ExtResource("28_j8jky")
flat = true
icon_alignment = 1
expand_icon = true
[node name="TektonGrabBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=2097928368]
[node name="TektonGrabBtn" type="Button" parent="TouchControls/TouchControls/PowerBarBtn" unique_id=2097928368]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
@@ -1471,8 +1460,15 @@ flat = true
icon_alignment = 1
expand_icon = true
[node name="GrabBtn" type="Button" parent="TouchControls/TouchControls/ActionsBtn" unique_id=914810452]
visible = false
[node name="InteractionBtn" type="VBoxContainer" parent="TouchControls/TouchControls" unique_id=1738242916]
layout_mode = 0
offset_left = 134.0
offset_top = 86.999985
offset_right = 216.0
offset_bottom = 254.0
rotation = -0.10297442
[node name="GrabBtn" type="Button" parent="TouchControls/TouchControls/InteractionBtn" unique_id=914810452]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
@@ -1482,17 +1478,15 @@ flat = true
icon_alignment = 1
expand_icon = true
[node name="SettingsBtn" type="Button" parent="TouchControls/TouchControls" unique_id=1964422444]
layout_mode = 1
anchors_preset = 1
anchor_left = 1.0
anchor_right = 1.0
offset_left = -78.0
offset_top = -302.0
offset_right = -30.0
offset_bottom = -254.0
grow_horizontal = 0
text = "⚙"
[node name="PutBtn" type="Button" parent="TouchControls/TouchControls/InteractionBtn" unique_id=1027790362]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 3
focus_mode = 0
icon = ExtResource("26_5q0nq")
flat = true
icon_alignment = 1
expand_icon = true
[node name="PauseMenu" type="CanvasLayer" parent="." unique_id=181131829]
process_mode = 3
@@ -1701,7 +1695,7 @@ text = "[b]Basic Controls[/b]
• [b]Interact:[/b] Click or tap on game elements.
• [b]GRAB TILE:[/b] Spacebar (in some modes) or Click to pick up a tile.
• [b]GRAB TEKTON (G):[/b] Grab a nearby Tekton to carry it.
• [b]SPAWN TILES (E):[/b] While carrying a Tekton, spawn 5 common tiles around you.
• [b]SPAWN TILES (G):[/b] While carrying a Tekton, spawn 5 common tiles around you.
• [b]ARRANGE:[/b] Insert a carried tile into your 3x3 Player Board."
[node name="The Grid" type="MarginContainer" parent="HowToPlayPanel/Panel/VBox/TabContainer" unique_id=123456807]
@@ -1739,7 +1733,7 @@ text = "[b]Tektons[/b]
• [b]Dynamic Tektons:[/b] Roaming metallic entities. Grab them to gain special benefits!
• [b]Grab & Hold (G):[/b] While holding a Tekton, you are [color=green][b]IMMUNE[/b][/color] to being knocked or staggered by others.
• [b]Tile Generation (E):[/b] Use your boost to force a carried Tekton to spawn 5 [b]Common Tiles[/b] instantly. The Tekton is released after spawning.
• [b]Tile Generation (G):[/b] Use your boost to force a carried Tekton to spawn 5 [b]Common Tiles[/b] instantly. The Tekton is released after spawning.
• [b]Static Tektons:[/b] Stationary sentry turrets that occupy a 3x3 space. They periodically throw tiles and obstacles around themselves. Stay alert!"
[node name="Skills" type="MarginContainer" parent="HowToPlayPanel/Panel/VBox/TabContainer" unique_id=123456811]
+5 -22
View File
@@ -455,19 +455,19 @@ custom_minimum_size = Vector2(150, 40)
layout_mode = 2
text = "N/A"
[node name="SpawnBoostLabel" type="Label" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/PowerBarGrid" unique_id=100000031]
[node name="TektonGrabLabel" type="Label" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/PowerBarGrid" unique_id=100000040]
layout_mode = 2
size_flags_horizontal = 3
text = "Spawn Boost"
text = "Grab Tekton"
label_settings = SubResource("LabelSettings_heading")
[node name="SpawnBoostBtn" type="Button" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/PowerBarGrid" unique_id=100000032]
[node name="TektonGrabBtn" type="Button" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/PowerBarGrid" unique_id=100000041]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 40)
layout_mode = 2
text = "E"
text = "G"
[node name="SpawnBoostAltBtn" type="Button" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/PowerBarGrid" unique_id=100000132]
[node name="TektonGrabAltBtn" type="Button" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/PowerBarGrid" unique_id=100000141]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 40)
layout_mode = 2
@@ -524,20 +524,3 @@ custom_minimum_size = Vector2(150, 40)
layout_mode = 2
text = "N/A"
[node name="TektonGrabLabel" type="Label" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/OtherGrid" unique_id=100000040]
layout_mode = 2
size_flags_horizontal = 3
text = "Grab Tekton"
label_settings = SubResource("LabelSettings_heading")
[node name="TektonGrabBtn" type="Button" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/OtherGrid" unique_id=100000041]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 40)
layout_mode = 2
text = "G"
[node name="TektonGrabAltBtn" type="Button" parent="PanelContainer/VBoxContainer/ContentSection/TabContainer/Controls/VBox/OtherGrid" unique_id=100000141]
unique_name_in_owner = true
custom_minimum_size = Vector2(150, 40)
layout_mode = 2
text = "N/A"
+5 -8
View File
@@ -92,15 +92,12 @@ func handle_unhandled_input(event):
player.enter_attack_mode()
get_viewport().set_input_as_handled()
elif event.is_action_pressed("spawn_boost"):
if player.is_carrying_tekton and player.powerup_manager:
if player.powerup_manager.has_method("spawn_boost_reward"):
player.powerup_manager.spawn_boost_reward()
get_viewport().set_input_as_handled()
elif event.is_action_pressed("action_grab_tekton"):
if not player.is_carrying_tekton and player.powerup_manager:
if player.powerup_manager.has_method("can_use_special"): # Corrected method name
if player.is_carrying_tekton:
if player.powerup_manager and player.powerup_manager.has_method("spawn_boost_reward"):
player.powerup_manager.spawn_boost_reward()
else:
if player.powerup_manager and player.powerup_manager.has_method("can_use_special"):
player.grab_tekton()
get_viewport().set_input_as_handled()
+2 -5
View File
@@ -55,9 +55,7 @@ var settings = {
# Power Bar Controls / Special
"attack_mode": KEY_Q,
"attack_mode_alt": KEY_U,
"spawn_boost": KEY_E,
"spawn_boost_alt": KEY_I
"attack_mode_alt": KEY_U
}
}
@@ -171,8 +169,7 @@ func apply_control_settings():
"put": "action_put",
"use_powerup": "use_powerup",
"tekton_grab": "action_grab_tekton",
"attack_mode": "action_knock_tekton",
"spawn_boost": "spawn_boost"
"attack_mode": "action_knock_tekton"
}
for setting_key in mapping.keys():
+64 -58
View File
@@ -8,7 +8,8 @@ signal attack_mode_pressed
# Touch control nodes
var virtual_joystick: Control
var actions_container: Control # New container
var power_bar_container: Control # Renamed from actions_container
var interaction_container: Control # New container for Interaction
var grab_button: Button
var put_button: Button
var attack_mode_button: Button # Renamed from special_button
@@ -57,9 +58,14 @@ func _on_control_remapped(_action: String, _key: int):
if spawn_boost_button: _ensure_shortcut_label(spawn_boost_button, "SpawnBoost")
if tekton_grab_button: _ensure_shortcut_label(tekton_grab_button, "TektonGrab")
# Also check all direct children of actions_container just in case
if actions_container:
for child in actions_container.get_children():
# Also check all direct children of containers just in case
if power_bar_container:
for child in power_bar_container.get_children():
if child is Button:
var b_name = child.name.replace("Btn", "")
_ensure_shortcut_label(child, b_name)
if interaction_container:
for child in interaction_container.get_children():
if child is Button:
var b_name = child.name.replace("Btn", "")
_ensure_shortcut_label(child, b_name)
@@ -141,73 +147,74 @@ func _create_touch_ui():
if not virtual_joystick.direction_changed.is_connected(_on_joystick_direction):
virtual_joystick.direction_changed.connect(_on_joystick_direction)
# --- Actions Container ---
actions_container = container.get_node_or_null("ActionsBtn")
if not actions_container:
actions_container = Control.new()
actions_container.name = "ActionsBtn"
actions_container.set_anchors_preset(Control.PRESET_FULL_RECT) # Or appropriate preset
actions_container.mouse_filter = Control.MOUSE_FILTER_PASS
container.add_child(actions_container)
# --- Actions Containers ---
power_bar_container = container.get_node_or_null("PowerBarBtn")
if not power_bar_container:
power_bar_container = container.get_node_or_null("ActionsBtn") # Fallback
interaction_container = container.get_node_or_null("InteractionBtn")
# Create containers if missing (runtime dynamic creation)
if not power_bar_container:
power_bar_container = Control.new()
power_bar_container.name = "PowerBarBtn"
power_bar_container.set_anchors_preset(Control.PRESET_FULL_RECT)
power_bar_container.mouse_filter = Control.MOUSE_FILTER_PASS
container.add_child(power_bar_container)
else:
print("[TouchControls] Found existing ActionsBtn container")
print("[TouchControls] Found existing PowerBarBtn container")
# Center buttons in the container instead of spreading them out
if actions_container is BoxContainer:
actions_container.alignment = BoxContainer.ALIGNMENT_CENTER
if not interaction_container:
interaction_container = Control.new()
interaction_container.name = "InteractionBtn"
interaction_container.set_anchors_preset(Control.PRESET_FULL_RECT)
interaction_container.mouse_filter = Control.MOUSE_FILTER_PASS
container.add_child(interaction_container)
else:
print("[TouchControls] Found existing InteractionBtn container")
# Create action buttons (parented to actions_container if possible, or use logic)
# User Request: "move those button to ActionsBtn children"
# Style/Align Containers
if power_bar_container is BoxContainer:
power_bar_container.alignment = BoxContainer.ALIGNMENT_CENTER
if interaction_container is BoxContainer:
interaction_container.alignment = BoxContainer.ALIGNMENT_CENTER
attack_mode_button = _find_or_create_action_button(actions_container, "AttackMode", "", button_positions.attack_mode) # Renamed
# spawn_boost_button = _find_or_create_action_button(actions_container, "SpawnBoost", "🚀", button_positions.spawn_boost)
grab_button = _find_or_create_action_button(actions_container, "Grab", "👋", button_positions.grab)
put_button = _find_or_create_action_button(actions_container, "Put", "📦", button_positions.put)
tekton_grab_button = _find_or_create_action_button(actions_container, "TektonGrab", "👋", Vector2(-280, -80))
# Create action buttons
attack_mode_button = _find_or_create_action_button(power_bar_container, "AttackMode", "", button_positions.attack_mode)
tekton_grab_button = _find_or_create_action_button(power_bar_container, "TektonGrab", "👋", Vector2(-280, -80))
grab_button = _find_or_create_action_button(interaction_container, "Grab", "👋", button_positions.grab)
put_button = _find_or_create_action_button(interaction_container, "Put", "📦", button_positions.put)
# Order: AttackMode, SpawnBoost, Grab, TektonGrab
# Order / Icons
if attack_mode_button:
actions_container.move_child(attack_mode_button, 0)
attack_mode_button.icon = load("res://assets/graphics/touch_control/attack_mode.png")
attack_mode_button.expand_icon = true
# if spawn_boost_button:
# actions_container.move_child(spawn_boost_button, 1)
# spawn_boost_button.icon = load("res://assets/graphics/touch_control/spawn_tile.png")
# spawn_boost_button.expand_icon = true
if grab_button:
actions_container.move_child(grab_button, 2)
grab_button.icon = load("res://assets/graphics/touch_control/take_tile.png")
grab_button.expand_icon = true
if tekton_grab_button:
actions_container.move_child(tekton_grab_button, 3)
tekton_grab_button.icon = load("res://assets/graphics/touch_control/grab_tekton.png")
tekton_grab_button.expand_icon = true
# Hide Put Button
if put_button:
put_button.visible = false
put_button.visible = true
# Create settings button (top-right corner)
settings_button = container.get_node_or_null("SettingsBtn")
# Use existing settings button (child of Main node)
settings_button = main_scene.get_node_or_null("SettingsBtn")
if not settings_button:
settings_button = Button.new()
settings_button.name = "SettingsBtn"
settings_button.text = ""
settings_button.set_anchors_preset(Control.PRESET_TOP_RIGHT)
settings_button.offset_left = -70
settings_button.offset_right = -20
settings_button.offset_top = 70
settings_button.offset_bottom = 120
settings_button.custom_minimum_size = Vector2(50, 50)
settings_button.mouse_filter = Control.MOUSE_FILTER_STOP
_style_button(settings_button, 0.5)
container.add_child(settings_button)
# Fallback to local search just in case
settings_button = container.get_node_or_null("SettingsBtn")
if settings_button:
print("[TouchControls] Found existing SettingsBtn on main scene")
# Ensure it's not hidden by mistake
settings_button.visible = true
if not settings_button.pressed.is_connected(_on_settings_pressed):
settings_button.pressed.connect(_on_settings_pressed)
@@ -306,9 +313,8 @@ func _ensure_shortcut_label(btn: Button, button_name: String):
match button_name:
"Grab": existing_lbl.text = SettingsManager.get_control_text("grab")
"Put": existing_lbl.text = ""
"Put": existing_lbl.text = SettingsManager.get_control_text("put")
"AttackMode": existing_lbl.text = SettingsManager.get_control_text("attack_mode")
# "SpawnBoost": existing_lbl.text = SettingsManager.get_control_text("spawn_boost")
"TektonGrab": existing_lbl.text = SettingsManager.get_control_text("tekton_grab")
@@ -339,9 +345,8 @@ func _ensure_shortcut_label(btn: Button, button_name: String):
match button_name:
"Grab": shortcut_lbl.text = SettingsManager.get_control_text("grab") if SettingsManager else "Space"
"Put": shortcut_lbl.text = "" # Disabled shortcut
"Put": shortcut_lbl.text = SettingsManager.get_control_text("put") if SettingsManager else "R"
"AttackMode": shortcut_lbl.text = SettingsManager.get_control_text("attack_mode") if SettingsManager else "Q"
# "SpawnBoost": shortcut_lbl.text = SettingsManager.get_control_text("spawn_boost") if SettingsManager else "E"
"TektonGrab": shortcut_lbl.text = SettingsManager.get_control_text("tekton_grab") if SettingsManager else "G"
@@ -495,17 +500,18 @@ func _apply_settings():
virtual_joystick.visible = joystick_enabled
# Apply touch buttons visibility - FORCED ON per request to "just show them"
if actions_container:
actions_container.visible = true
actions_container.set_anchors_preset(Control.PRESET_FULL_RECT)
actions_container.mouse_filter = Control.MOUSE_FILTER_PASS
# Apply touch buttons visibility
if power_bar_container:
power_bar_container.visible = true
if interaction_container:
interaction_container.visible = true
var buttons_visible = true
print("[TouchControls] Applying settings: ButtonsVisible=", buttons_visible)
if grab_button:
grab_button.visible = false
grab_button.visible = true
grab_button.scale = Vector2(button_scale, button_scale)
grab_button.set_anchors_preset(Control.PRESET_BOTTOM_RIGHT)
grab_button.offset_left = button_positions.grab.x
@@ -514,7 +520,7 @@ func _apply_settings():
grab_button.offset_bottom = button_positions.grab.y + button_size
if put_button:
put_button.visible = false # Always INTENTIONALLY HIDDEN per request
put_button.visible = true
if attack_mode_button:
attack_mode_button.visible = true
@@ -617,7 +623,7 @@ func _on_tekton_carried_changed(_is_carrying: bool):
# Swapping to Spawn function (Hotkey E)
tekton_grab_button.icon = load("res://assets/graphics/touch_control/spawn_tile.png")
if SettingsManager:
_ensure_shortcut_label(tekton_grab_button, "SpawnBoost")
_ensure_shortcut_label(tekton_grab_button, "TektonGrab")
else:
# Swapping back to Grab function (Hotkey G)
tekton_grab_button.icon = load("res://assets/graphics/touch_control/grab_tekton.png")