ios上的godot角色移动

问题描述

我正在使用 godot 构建游戏。

这是我的角色移动代码

func Movement():
if Input.is_action_pressed("Right") and not Input.is_action_pressed("Left"):
    veLocity.x = min(veLocity.x + acceleration,MAX_SPEED)
    flip = "Right"
    if get_node("Hand").position.x < 0: 
        flip()
    get_node("Camera2D").offset_h = 1 
elif Input.is_action_pressed("Left") and not Input.is_action_pressed("Right"):
    veLocity.x = max(veLocity.x - acceleration,-MAX_SPEED)
    flip = "Left"
    if get_node("Hand").position.x > 0: 
        flip()
    get_node("Camera2D").offset_h = -1 
else:
    veLocity.x = 0

它在 android 上工作正常,但在 ios 上我必须长按我使用的 touchScreenButton 以便 人物动作 有没有办法像在 android 上一样在触摸上工作

我在 (input_devices/pointing/ios/touch_delay) 中将延迟减少到 0.005 但没有任何变化。我仍然必须按下按钮而不是触摸它,我使用了触摸屏按钮,但是在 ios 中我必须按下它才能使角色移动,这与我必须触摸按钮才能使角色移动的 android 不同

解决方法

默认情况下,iOS 上的触摸有 150 毫秒的延迟(但在 Android 上没有)。这是操作系统出于各种原因强加的,但您可以decrease this value in the project settings (input_devices/pointing/ios/touch_delay) 并再次将项目导出到 iOS。

可以在this GitHub issue中找到更多解释。