Skip to content

Commit af8a422

Browse files
committed
fix touch screen buttons ghosting!
release() all actions when changing action sets
1 parent c2cc62c commit af8a422

2 files changed

Lines changed: 17 additions & 24 deletions

File tree

src/autoload/touch_screen.gd

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ onready var top := $Control/HBoxTop
55

66
onready var keys := [$Control/HBoxRight/C, $Control/HBoxRight/X]
77
onready var buttons := [$Control/HBoxRight/C/Control/Button, $Control/HBoxRight/X/Control/Button]
8-
onready var joystick := $Control/Joystick
98

10-
onready var btns := $Control/Joystick/Buttons.get_children()
9+
onready var btns := $Control/DPad/Buttons.get_children()
10+
onready var actions := InputMap.get_actions()
1111

1212
func _ready():
1313
connect("visibility_changed", self, "vis")
@@ -31,6 +31,10 @@ func set_game(arg := false):
3131
set_actions(i + "up", i + "down", i + "left", i + "right")
3232
buttons[0].action = "action" if arg else "ui_no"
3333
buttons[1].action = "jump" if arg else "ui_yes"
34+
35+
for a in actions:
36+
Input.action_release(a)
37+
3438
for f in buttons:
3539
f.passby_press = arg
3640

src/autoload/touch_screen.tscn

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
[gd_scene load_steps=15 format=2]
1+
[gd_scene load_steps=14 format=2]
22

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

109
[sub_resource type="CircleShape2D" id=3]
1110
radius = 15.0
@@ -175,28 +174,18 @@ margin_top = -6.0
175174
margin_right = 5.0
176175
margin_bottom = 6.0
177176

178-
[node name="Joystick" type="Control" parent="Control"]
177+
[node name="DPad" type="Control" parent="Control"]
179178
margin_left = 26.0
180179
margin_top = 98.0
181180
margin_right = 26.0
182181
margin_bottom = 98.0
183182
rect_pivot_offset = Vector2( -84, -71 )
184183

185-
[node name="Base" type="Control" parent="Control/Joystick"]
186-
visible = false
187-
grow_horizontal = 2
188-
grow_vertical = 2
189-
size_flags_horizontal = 4
190-
size_flags_vertical = 4
191-
script = ExtResource( 8 )
192-
radius = 20.0
193-
points = 16
194-
195-
[node name="Buttons" type="Control" parent="Control/Joystick"]
184+
[node name="Buttons" type="Control" parent="Control/DPad"]
196185
margin_right = 40.0
197186
margin_bottom = 40.0
198187

199-
[node name="0" type="TouchScreenButton" parent="Control/Joystick/Buttons"]
188+
[node name="0" type="TouchScreenButton" parent="Control/DPad/Buttons"]
200189
shape = SubResource( 7 )
201190
shape_centered = false
202191
action = "ui_right"
@@ -205,15 +194,15 @@ poly_path = NodePath("Polygon2D")
205194
inner_radius = 18.0
206195
inner_offset = 2.0
207196

208-
[node name="Polygon2D" type="Polygon2D" parent="Control/Joystick/Buttons/0"]
197+
[node name="Polygon2D" type="Polygon2D" parent="Control/DPad/Buttons/0"]
209198
modulate = Color( 1, 1, 1, 0.3 )
210199
position = Vector2( 2, 0 )
211200
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 )
212201
script = ExtResource( 4 )
213202
button_path = NodePath("..")
214203
idle_color = Color( 1, 1, 1, 0.501961 )
215204

216-
[node name="1" type="TouchScreenButton" parent="Control/Joystick/Buttons"]
205+
[node name="1" type="TouchScreenButton" parent="Control/DPad/Buttons"]
217206
shape = SubResource( 8 )
218207
shape_centered = false
219208
action = "ui_down"
@@ -223,14 +212,14 @@ poly_path = NodePath("Polygon2D")
223212
inner_radius = 18.0
224213
inner_offset = 2.0
225214

226-
[node name="Polygon2D" type="Polygon2D" parent="Control/Joystick/Buttons/1"]
215+
[node name="Polygon2D" type="Polygon2D" parent="Control/DPad/Buttons/1"]
227216
modulate = Color( 1, 1, 1, 0.3 )
228217
position = Vector2( -8.74228e-08, 2 )
229218
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 )
230219
script = ExtResource( 4 )
231220
button_path = NodePath("..")
232221

233-
[node name="2" type="TouchScreenButton" parent="Control/Joystick/Buttons"]
222+
[node name="2" type="TouchScreenButton" parent="Control/DPad/Buttons"]
234223
shape = SubResource( 9 )
235224
shape_centered = false
236225
action = "ui_left"
@@ -240,14 +229,14 @@ poly_path = NodePath("Polygon2D")
240229
inner_radius = 18.0
241230
inner_offset = 2.0
242231

243-
[node name="Polygon2D" type="Polygon2D" parent="Control/Joystick/Buttons/2"]
232+
[node name="Polygon2D" type="Polygon2D" parent="Control/DPad/Buttons/2"]
244233
modulate = Color( 1, 1, 1, 0.3 )
245234
position = Vector2( -2, -1.74846e-07 )
246235
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 )
247236
script = ExtResource( 4 )
248237
button_path = NodePath("..")
249238

250-
[node name="3" type="TouchScreenButton" parent="Control/Joystick/Buttons"]
239+
[node name="3" type="TouchScreenButton" parent="Control/DPad/Buttons"]
251240
shape = SubResource( 10 )
252241
shape_centered = false
253242
action = "ui_up"
@@ -257,7 +246,7 @@ poly_path = NodePath("Polygon2D")
257246
inner_radius = 18.0
258247
inner_offset = 2.0
259248

260-
[node name="Polygon2D" type="Polygon2D" parent="Control/Joystick/Buttons/3"]
249+
[node name="Polygon2D" type="Polygon2D" parent="Control/DPad/Buttons/3"]
261250
modulate = Color( 1, 1, 1, 0.3 )
262251
position = Vector2( 2.38498e-08, -2 )
263252
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 )

0 commit comments

Comments
 (0)