Add capability for touch controls

This commit is contained in:
Stephen Seo 2023-12-21 17:10:19 +09:00
parent a2b612472e
commit c7453c5467
4 changed files with 67 additions and 9 deletions

View file

@ -35,11 +35,15 @@ var particle = preload("res://circleParticle.tscn")
@onready var title_text = $GameTitleText
var title_timer = 5.0
@onready var touch_jump = $JumpTouchButton
@onready var touch_left = $LeftTouchButton
@onready var touch_right = $RightTouchButton
func _ready():
self_sprite.self_modulate = DEFAULT_COLOR
health_label.add_text(health_text_format % health)
title_text.add_theme_font_size_override("normal_font_size", 40)
title_text.add_text("LD54 - Box Survival\nBy: BurnedKirby\nMade in Godot")
title_text.add_text("LD54 - Box Survival\nBy: BurnedKirby\nMade in Godot\nWAD or Touch to move")
func _physics_process(delta):
if title_timer > 0.0:
@ -110,3 +114,6 @@ func damaged(projectile):
for i in range(100):
spawn_particle(Color(1, 1, 1))
get_parent().on_player_death()
touch_jump.hide()
touch_left.hide()
touch_right.hide()

View file

@ -8,7 +8,7 @@ custom_features=""
export_filter="all_resources"
include_filter=""
exclude_filter=""
export_path="html_export/LD54.html"
export_path="html_export/ld54.html"
encryption_include_filters=""
encryption_exclude_filters=""
encrypt_pck=false
@ -20,7 +20,7 @@ custom_template/debug=""
custom_template/release=""
variant/extensions_support=false
vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
vram_texture_compression/for_mobile=true
html/export_icon=true
html/custom_html_shell=""
html/head_include=""

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://dv8hwks0xe3c0"]
[gd_scene load_steps=8 format=3 uid="uid://dv8hwks0xe3c0"]
[ext_resource type="Script" path="res://PlayerCharacterBody2D.gd" id="1_8l13s"]
[ext_resource type="AudioStream" uid="uid://b88dh38cr8v6o" path="res://res/jump.ogg" id="2_ix2ut"]
@ -9,6 +9,15 @@ size = Vector2(40, 40)
[sub_resource type="CanvasTexture" id="CanvasTexture_ruce8"]
[sub_resource type="Gradient" id="Gradient_v7mm3"]
colors = PackedColorArray(1, 1, 1, 0.454902, 1, 1, 1, 0)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_iin72"]
gradient = SubResource("Gradient_v7mm3")
fill = 1
fill_from = Vector2(0.5, 0.5)
fill_to = Vector2(1, 0.5)
[node name="CharacterBody2D" type="CharacterBody2D"]
position = Vector2(590, 561)
collision_layer = 3
@ -22,6 +31,42 @@ debug_color = Color(0, 0.6, 0.701961, 0.419608)
scale = Vector2(40, 40)
texture = SubResource("CanvasTexture_ruce8")
[node name="JumpTouchButton" type="TouchScreenButton" parent="."]
position = Vector2(-32.9999, -95)
texture_normal = SubResource("GradientTexture2D_iin72")
action = "jump"
[node name="Label" type="Label" parent="JumpTouchButton"]
offset_left = 12.0
offset_top = 19.0
offset_right = 53.0
offset_bottom = 42.0
text = "Jump"
[node name="RightTouchButton" type="TouchScreenButton" parent="."]
position = Vector2(40, -30)
texture_normal = SubResource("GradientTexture2D_iin72")
action = "right"
[node name="Label" type="Label" parent="RightTouchButton"]
offset_left = 12.0
offset_top = 19.0
offset_right = 53.0
offset_bottom = 42.0
text = "Right"
[node name="LeftTouchButton" type="TouchScreenButton" parent="."]
position = Vector2(-103, -30)
texture_normal = SubResource("GradientTexture2D_iin72")
action = "left"
[node name="Label" type="Label" parent="LeftTouchButton"]
offset_left = 18.0
offset_top = 20.0
offset_right = 59.0
offset_bottom = 43.0
text = "Left"
[node name="Camera2D" type="Camera2D" parent="."]
[node name="RichTextLabel" type="RichTextLabel" parent="."]
@ -43,7 +88,8 @@ stream = ExtResource("2_ix2ut")
stream = ExtResource("3_gq63f")
[node name="GameTitleText" type="RichTextLabel" parent="."]
offset_left = -137.0
offset_top = 74.0
offset_right = 336.0
offset_bottom = 293.0
offset_left = -138.0
offset_top = 46.0
offset_right = 335.0
offset_bottom = 286.0
scroll_active = false

View file

@ -12,7 +12,7 @@ config_version=5
config/name="LD54 - Box Survival"
run/main_scene="res://boxedSpace.tscn"
config/features=PackedStringArray("4.1", "GL Compatibility")
config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg"
[input]
@ -37,7 +37,12 @@ right={
]
}
[input_devices]
pointing/emulate_touch_from_mouse=true
[rendering]
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
textures/vram_compression/import_etc2_astc=true