Fix mobile restart and swipe aiming while firing
This commit is contained in:
+28
-1
@@ -68,6 +68,16 @@ func _ready() -> void:
|
||||
if DisplayServer.get_name() != "headless" and not OS.has_feature("web"):
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
|
||||
var restart_button: Button
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
# Touch nativo: funziona anche con emulate_mouse_from_touch disattivato.
|
||||
if event is InputEventScreenTouch and event.pressed and is_instance_valid(restart_button):
|
||||
if not restart_button.disabled and restart_button.get_global_rect().has_point(event.position):
|
||||
restart_button.disabled = true
|
||||
get_viewport().set_input_as_handled()
|
||||
get_tree().call_deferred("reload_current_scene")
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if OS.has_feature("web") and not touch_mode and event is InputEventMouseButton and event.pressed and event.button_index == MOUSE_BUTTON_LEFT and not death_started:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
@@ -211,10 +221,27 @@ func _die() -> void:
|
||||
tween.tween_property(camera, "rotation:x", 0.08, 0.9)
|
||||
tween.tween_property(death_overlay, "color:a", 1.0, 1.8).set_delay(0.7)
|
||||
var message := Label.new()
|
||||
message.text = "SEI MORTO\nPremi R per ricominciare"
|
||||
message.text = "SEI MORTO" if touch_mode else "SEI MORTO\nPremi R per ricominciare"
|
||||
message.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
message.add_theme_font_size_override("font_size", 36)
|
||||
message.modulate.a = 0
|
||||
layer.add_child(message)
|
||||
message.set_anchors_and_offsets_preset(Control.PRESET_CENTER)
|
||||
tween.tween_property(message, "modulate:a", 1.0, 0.5).set_delay(2.2)
|
||||
if touch_mode:
|
||||
var restart := Button.new()
|
||||
restart_button = restart
|
||||
restart.name = "RestartButton"
|
||||
restart.text = "RICOMINCIA"
|
||||
restart.add_theme_font_size_override("font_size", 28)
|
||||
layer.add_child(restart)
|
||||
restart.set_anchors_and_offsets_preset(Control.PRESET_CENTER)
|
||||
restart.offset_left = -150
|
||||
restart.offset_right = 150
|
||||
restart.offset_top = 90
|
||||
restart.offset_bottom = 162
|
||||
restart.disabled = true
|
||||
get_tree().create_timer(0.6).timeout.connect(func(): restart.disabled = false)
|
||||
restart.pressed.connect(func():
|
||||
restart.disabled = true
|
||||
get_tree().reload_current_scene())
|
||||
|
||||
Reference in New Issue
Block a user