Skip to content

Commit

Permalink
bring up touch controls after touching screen
Browse files Browse the repository at this point in the history
hide from view when pressing keyboard or gamepad
is_touch: 0 = TOGGLE, 1 = ALWAYS
TOGGLE is default behavior
ALWAYS will keep Touch Controls on screen
  • Loading branch information
HarmonyHoney committed Dec 7, 2024
1 parent d38503f commit c8113ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/autoload/touch_screen.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ func _ready():
yield(Shared, "scene_changed")
visible = Shared.is_touch or ((OS.has_touchscreen_ui_hint() and OS.get_name() == "HTML5") or OS.get_name() == "Android")

func _input(event):
if !Shared.is_touch:
var d = event is InputEventScreenDrag
var t = event is InputEventScreenTouch
var k = event is InputEventKey
var b = event is InputEventJoypadButton
var m = event is InputEventJoypadMotion

if d or t or k or b or m:
visible = d or t

func show_keys(arg_arrows := true, arg_c := true, arg_x := true, arg_pause := false, arg_passby := false):
right.visible = arg_arrows
keys[0].visible = arg_c
Expand Down
1 change: 1 addition & 0 deletions src/menu/options/MenuOptions.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ script = ExtResource( 24 )
__meta__ = {
"_edit_use_anchors_": false
}
list = PoolStringArray( "TOGGLE", "ALWAYS" )
is_refill = true
var_name = "is_touch"

Expand Down

0 comments on commit c8113ab

Please sign in to comment.