From f2b3c4b7f031296951efa907518d7306a27d1015 Mon Sep 17 00:00:00 2001 From: jbourqueendless <164198892+jbourqueendless@users.noreply.github.com> Date: Mon, 2 Dec 2024 18:11:07 -0500 Subject: [PATCH] adding three buttons for touch screen uing control ui node and a few button nodes --- main.tscn | 43 ++++---------------------------------- project.godot | 2 +- touch_screen_controls.tscn | 30 ++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 40 deletions(-) create mode 100644 touch_screen_controls.tscn diff --git a/main.tscn b/main.tscn index bba525b..3d71600 100644 --- a/main.tscn +++ b/main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=18 format=3 uid="uid://dhcpt1kt8cs0g"] +[gd_scene load_steps=15 format=3 uid="uid://dhcpt1kt8cs0g"] [ext_resource type="PackedScene" uid="uid://8st4scqt06l8" path="res://components/player/player.tscn" id="2_7yl00"] [ext_resource type="PackedScene" uid="uid://jnrusvm3gric" path="res://spaces/background.tscn" id="2_tb5a2"] @@ -13,10 +13,7 @@ [ext_resource type="SpriteFrames" uid="uid://bo581k1esb50n" path="res://components/player/spriteframes-red.tres" id="9_qmofe"] [ext_resource type="PackedScene" uid="uid://beuisy5yrw0bq" path="res://components/flag/flag.tscn" id="12_dkbog"] [ext_resource type="Script" path="res://scripts/multiplayer_camera.gd" id="13_0d2mj"] -[ext_resource type="Texture2D" uid="uid://dnq46nmf2skjg" path="res://assets/Touchscreen Controls/kenney_onscreen-controls/Sprites/flat-light/flatLight22.png" id="14_5ab13"] -[ext_resource type="Texture2D" uid="uid://cbieuf3n6iqko" path="res://assets/Touchscreen Controls/kenney_onscreen-controls/Sprites/flat-light/flatLight25.png" id="14_g23fj"] -[ext_resource type="Texture2D" uid="uid://dsght3iwomray" path="res://assets/Touchscreen Controls/kenney_onscreen-controls/Sprites/flat-light/flatLight23.png" id="15_twkht"] -[ext_resource type="Texture2D" uid="uid://djok3hg16clb2" path="res://assets/Touchscreen Controls/kenney_onscreen-controls/Sprites/flat-light/flatLight24.png" id="16_cmlt1"] +[ext_resource type="PackedScene" uid="uid://dhu8h331t4p0o" path="res://touch_screen_controls.tscn" id="14_3oook"] [node name="Main" type="Node2D"] @@ -237,37 +234,5 @@ script = ExtResource("13_0d2mj") [node name="CanvasLayer" type="CanvasLayer" parent="."] -[node name="Control" type="Control" parent="CanvasLayer"] -layout_mode = 3 -anchor_left = 0.041 -anchor_top = 0.656 -anchor_right = 0.262 -anchor_bottom = 1.006 -offset_left = 37.28 -offset_top = 5.51996 -offset_right = 37.96 -offset_bottom = 4.5199 - -[node name="MoveDownButton" type="TouchScreenButton" parent="CanvasLayer/Control"] -position = Vector2(127, 221) -scale = Vector2(1.775, 1.8625) -texture_normal = ExtResource("14_g23fj") -action = "player_1_left" - -[node name="MoveRightButton" type="TouchScreenButton" parent="CanvasLayer/Control"] -position = Vector2(250, 93) -scale = Vector2(1.775, 1.8625) -texture_normal = ExtResource("15_twkht") -action = "player_1_left" - -[node name="MoveUpButton" type="TouchScreenButton" parent="CanvasLayer/Control"] -position = Vector2(120, -20) -scale = Vector2(1.775, 1.8625) -texture_normal = ExtResource("16_cmlt1") -action = "player_1_left" - -[node name="MoveLeftButton4" type="TouchScreenButton" parent="CanvasLayer/Control"] -position = Vector2(-4, 101) -scale = Vector2(1.775, 1.8625) -texture_normal = ExtResource("14_5ab13") -action = "player_1_left" +[node name="TouchScreenControls" parent="CanvasLayer" instance=ExtResource("14_3oook")] +anchors_preset = 15 diff --git a/project.godot b/project.godot index 773b786..682488a 100644 --- a/project.godot +++ b/project.godot @@ -30,7 +30,7 @@ window/stretch/mode="canvas_items" [editor_plugins] -enabled=PackedStringArray("res://addons/block_code/plugin.cfg") +enabled=PackedStringArray() [global_group] diff --git a/touch_screen_controls.tscn b/touch_screen_controls.tscn new file mode 100644 index 0000000..a2b51a3 --- /dev/null +++ b/touch_screen_controls.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=4 format=3 uid="uid://dhu8h331t4p0o"] + +[ext_resource type="Texture2D" uid="uid://dnq46nmf2skjg" path="res://assets/Touchscreen Controls/kenney_onscreen-controls/Sprites/flat-light/flatLight22.png" id="1_o68br"] +[ext_resource type="Texture2D" uid="uid://dsght3iwomray" path="res://assets/Touchscreen Controls/kenney_onscreen-controls/Sprites/flat-light/flatLight23.png" id="2_d4mmb"] +[ext_resource type="Texture2D" uid="uid://crocudarwwiec" path="res://assets/Touchscreen Controls/kenney_onscreen-controls/Sprites/flat-light/flatLight34.png" id="3_mqvem"] + +[node name="TouchScreenControls" type="Control"] +layout_mode = 3 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="MovePlayerLeft" type="TouchScreenButton" parent="."] +position = Vector2(79.4, 844.84) +scale = Vector2(2, 1.964) +texture_normal = ExtResource("1_o68br") +action = "player_1_left" + +[node name="MovePlayerRight" type="TouchScreenButton" parent="."] +position = Vector2(342.16, 844.84) +scale = Vector2(2, 2) +texture_normal = ExtResource("2_d4mmb") +action = "player_1_right" + +[node name="Jump" type="TouchScreenButton" parent="."] +position = Vector2(1695, 837) +scale = Vector2(2, 2) +texture_normal = ExtResource("3_mqvem") +action = "player_1_jump"