Skip to content

Commit 6490ffa

Browse files
committed
Add exit button to play screen
The previous commits neglected to provide a way for a touchscreen player to quit a level.
1 parent a7a1131 commit 6490ffa

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed

levels/comparison_sort.gd

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ func _input(event):
3333
if event is InputEventKey and event.is_pressed():
3434
return next(event.as_text())
3535
if event is InputEventMouseButton and event.is_pressed():
36-
if event.position.x < ProjectSettings.get_setting("display/window/size/width") / 2:
37-
return next("Left")
38-
else:
39-
return next("Right")
36+
if event.position.y > 100:
37+
if event.position.x < ProjectSettings.get_setting("display/window/size/width") / 2:
38+
return next("Left")
39+
else:
40+
return next("Right")
4041

4142
func next(action):
4243
"""Check the action and advance state or emit signal as needed."""

scenes/levels.tscn

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ margin_left = 178.0
3737
margin_right = 562.0
3838
margin_bottom = 19.0
3939
size_flags_horizontal = 3
40-
text = "<--"
41-
align = 2
40+
text = " <--"
41+
align = 0
4242

4343
[node name="Current" type="Button" parent="Levels/NamesContainer/Names"]
4444
margin_left = 570.0
@@ -54,8 +54,8 @@ margin_left = 648.0
5454
margin_right = 1032.0
5555
margin_bottom = 19.0
5656
size_flags_horizontal = 3
57-
text = "-->"
58-
align = 0
57+
text = "--> "
58+
align = 2
5959

6060
[node name="BigPicture" type="Button" parent="Levels/NamesContainer/Names"]
6161
margin_left = 1040.0

scenes/play.tscn

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,25 @@ margin_top = 20.0
2727
margin_right = 1220.0
2828
margin_bottom = 39.0
2929

30+
[node name="Exit" type="Button" parent="GameDisplay/HUDBorder/HUD"]
31+
margin_right = 40.0
32+
margin_bottom = 19.0
33+
text = "EXIT"
34+
align = 0
35+
3036
[node name="Level" type="Label" parent="GameDisplay/HUDBorder/HUD"]
31-
margin_right = 596.0
37+
margin_left = 48.0
38+
margin_right = 1142.0
3239
margin_bottom = 19.0
3340
size_flags_horizontal = 3
3441
text = "LEVEL"
42+
align = 1
3543

3644
[node name="Score" type="Label" parent="GameDisplay/HUDBorder/HUD"]
37-
margin_left = 604.0
45+
margin_left = 1150.0
3846
margin_right = 1200.0
3947
margin_bottom = 19.0
40-
size_flags_horizontal = 3
48+
size_flags_horizontal = 8
4149
text = "0.000"
4250
align = 2
4351

@@ -60,4 +68,5 @@ align = 1
6068
one_shot = true
6169
autostart = true
6270

71+
[connection signal="pressed" from="GameDisplay/HUDBorder/HUD/Exit" to="GameDisplay" method="_on_Exit_pressed"]
6372
[connection signal="timeout" from="GameDisplay/Timer" to="GameDisplay" method="_on_Timer_timeout"]

scripts/play.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ func _input(event):
2828

2929
func _on_Level_done():
3030
set_process(false)
31+
$HUDBorder/HUD/Exit.queue_free()
3132
var time = get_score()
3233
var restart = Button.new()
3334
restart.text = "RESTART LEVEL"
@@ -58,3 +59,6 @@ func _on_Button_pressed(scene):
5859
{"level": GlobalScene.get_param("level"),
5960
"size": GlobalScene.get_param("size"),
6061
"data_type": GlobalScene.get_param("data_type")})
62+
63+
func _on_Exit_pressed():
64+
_on_Button_pressed("levels")

0 commit comments

Comments
 (0)