Skip to content

Commit

Permalink
fix touch screen buttons ghosting!
Browse files Browse the repository at this point in the history
release() all actions when changing action sets
  • Loading branch information
HarmonyHoney committed Sep 22, 2024
1 parent c2cc62c commit af8a422
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 24 deletions.
8 changes: 6 additions & 2 deletions src/autoload/touch_screen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ onready var top := $Control/HBoxTop

onready var keys := [$Control/HBoxRight/C, $Control/HBoxRight/X]
onready var buttons := [$Control/HBoxRight/C/Control/Button, $Control/HBoxRight/X/Control/Button]
onready var joystick := $Control/Joystick

onready var btns := $Control/Joystick/Buttons.get_children()
onready var btns := $Control/DPad/Buttons.get_children()
onready var actions := InputMap.get_actions()

func _ready():
connect("visibility_changed", self, "vis")
Expand All @@ -31,6 +31,10 @@ func set_game(arg := false):
set_actions(i + "up", i + "down", i + "left", i + "right")
buttons[0].action = "action" if arg else "ui_no"
buttons[1].action = "jump" if arg else "ui_yes"

for a in actions:
Input.action_release(a)

for f in buttons:
f.passby_press = arg

Expand Down
33 changes: 11 additions & 22 deletions src/autoload/touch_screen.tscn
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[gd_scene load_steps=15 format=2]
[gd_scene load_steps=14 format=2]

[ext_resource path="res://src/autoload/touch_screen.gd" type="Script" id=1]
[ext_resource path="res://media/image/circle.png" type="Texture" id=2]
[ext_resource path="res://src/menu/round_button.gd" type="Script" id=3]
[ext_resource path="res://src/menu/button_modulate.gd" type="Script" id=4]
[ext_resource path="res://media/font/NicoPaint-Regular.ttf" type="DynamicFontData" id=5]
[ext_resource path="res://src/circle.gd" type="Script" id=8]

[sub_resource type="CircleShape2D" id=3]
radius = 15.0
Expand Down Expand Up @@ -175,28 +174,18 @@ margin_top = -6.0
margin_right = 5.0
margin_bottom = 6.0

[node name="Joystick" type="Control" parent="Control"]
[node name="DPad" type="Control" parent="Control"]
margin_left = 26.0
margin_top = 98.0
margin_right = 26.0
margin_bottom = 98.0
rect_pivot_offset = Vector2( -84, -71 )

[node name="Base" type="Control" parent="Control/Joystick"]
visible = false
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
script = ExtResource( 8 )
radius = 20.0
points = 16

[node name="Buttons" type="Control" parent="Control/Joystick"]
[node name="Buttons" type="Control" parent="Control/DPad"]
margin_right = 40.0
margin_bottom = 40.0

[node name="0" type="TouchScreenButton" parent="Control/Joystick/Buttons"]
[node name="0" type="TouchScreenButton" parent="Control/DPad/Buttons"]
shape = SubResource( 7 )
shape_centered = false
action = "ui_right"
Expand All @@ -205,15 +194,15 @@ poly_path = NodePath("Polygon2D")
inner_radius = 18.0
inner_offset = 2.0

[node name="Polygon2D" type="Polygon2D" parent="Control/Joystick/Buttons/0"]
[node name="Polygon2D" type="Polygon2D" parent="Control/DPad/Buttons/0"]
modulate = Color( 1, 1, 1, 0.3 )
position = Vector2( 2, 0 )
polygon = PoolVector2Array( 2.12132, 2.12132, 3, 0, 2.12132, -2.12132, 12.7279, -12.7279, 16.6298, -6.8883, 18, 0, 16.6298, 6.8883, 12.7279, 12.7279 )
script = ExtResource( 4 )
button_path = NodePath("..")
idle_color = Color( 1, 1, 1, 0.501961 )

[node name="1" type="TouchScreenButton" parent="Control/Joystick/Buttons"]
[node name="1" type="TouchScreenButton" parent="Control/DPad/Buttons"]
shape = SubResource( 8 )
shape_centered = false
action = "ui_down"
Expand All @@ -223,14 +212,14 @@ poly_path = NodePath("Polygon2D")
inner_radius = 18.0
inner_offset = 2.0

[node name="Polygon2D" type="Polygon2D" parent="Control/Joystick/Buttons/1"]
[node name="Polygon2D" type="Polygon2D" parent="Control/DPad/Buttons/1"]
modulate = Color( 1, 1, 1, 0.3 )
position = Vector2( -8.74228e-08, 2 )
polygon = PoolVector2Array( -2.12132, 2.12132, -1.31134e-07, 3, 2.12132, 2.12132, 12.7279, 12.7279, 6.8883, 16.6298, -7.86805e-07, 18, -6.8883, 16.6298, -12.7279, 12.7279 )
script = ExtResource( 4 )
button_path = NodePath("..")

[node name="2" type="TouchScreenButton" parent="Control/Joystick/Buttons"]
[node name="2" type="TouchScreenButton" parent="Control/DPad/Buttons"]
shape = SubResource( 9 )
shape_centered = false
action = "ui_left"
Expand All @@ -240,14 +229,14 @@ poly_path = NodePath("Polygon2D")
inner_radius = 18.0
inner_offset = 2.0

[node name="Polygon2D" type="Polygon2D" parent="Control/Joystick/Buttons/2"]
[node name="Polygon2D" type="Polygon2D" parent="Control/DPad/Buttons/2"]
modulate = Color( 1, 1, 1, 0.3 )
position = Vector2( -2, -1.74846e-07 )
polygon = PoolVector2Array( -2.12132, -2.12132, -3, -2.62268e-07, -2.12132, 2.12132, -12.7279, 12.7279, -16.6298, 6.8883, -18, -1.57361e-06, -16.6298, -6.8883, -12.7279, -12.7279 )
script = ExtResource( 4 )
button_path = NodePath("..")

[node name="3" type="TouchScreenButton" parent="Control/Joystick/Buttons"]
[node name="3" type="TouchScreenButton" parent="Control/DPad/Buttons"]
shape = SubResource( 10 )
shape_centered = false
action = "ui_up"
Expand All @@ -257,7 +246,7 @@ poly_path = NodePath("Polygon2D")
inner_radius = 18.0
inner_offset = 2.0

[node name="Polygon2D" type="Polygon2D" parent="Control/Joystick/Buttons/3"]
[node name="Polygon2D" type="Polygon2D" parent="Control/DPad/Buttons/3"]
modulate = Color( 1, 1, 1, 0.3 )
position = Vector2( 2.38498e-08, -2 )
polygon = PoolVector2Array( 2.12132, -2.12132, 3.57746e-08, -3, -2.12132, -2.12132, -12.7279, -12.7279, -6.8883, -16.6298, 2.14648e-07, -18, 6.8883, -16.6298, 12.7279, -12.7279 )
Expand Down

0 comments on commit af8a422

Please sign in to comment.