Godot Version
4.3
Question
In my first Godot game, I have 3 different UI screens (MainMenu, PauseMenu, GameOverMenu) and a game scene where user only has 1 action (rotation).
In Project Settings > Input Map I only have 1 input (rotation - Spacebar)
In Project Settings > Input Devices > Pointing > emulate_touch_from_mouse is turned on and emulate_mouse_from_touch is turned off.
When I launch the game, with LMB I can navigate through different Menus and also do action with a LMB indicating that the game either has touch support already or LMB is the default input I can’t remove (although it’s not in the Input Map).
In my player.gd I have
func _input(event: InputEvent) -> void:
if Input.is_action_just_pressed("Rotate"):
if Animation_Player.is_playing():
return
Rotate()
if event is InputEventScreenTouch:
if event.pressed:
if not $"/root/Game/ActiveUI/MarginContainer/HBoxContainer/PauseButton".get_global_rect().has_point(event.position):
if Animation_Player.is_playing():
return
Rotate()
Now, the whole idea of touch input here is that the Menu buttons work as usual and once the main game scene starts, user input anywhere on the screen (except the PauseButton) would cause action and landing on PauseButton would call the PauseMenu and pause the game.
Part of pause_button.gd
func _ready() -> void:
pressed.connect(_on_pause_button_pressed)
func _input(event: InputEvent) -> void:
if event is InputEventKey and event.keycode == Key.KEY_ESCAPE and event.pressed and not event.is_echo():
_on_pause_button_pressed()
accept_event()
func _gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed:
_on_pause_button_pressed()
accept_event()
Exporting the game to itch io and trying on mobile I couldn’t get past the MainMenu screen. Is there something else? Do I need to create a whole overlay of ‘touch buttons’ for every single menu button? How would I connect them? Do I need a completely seperate project that would handle only touch input in order for this to be a mobile game?