首页 > 解决方案 > 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,所以角色 mocve 有一种方法可以像在 android 上一样在触摸上工作

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

标签: iosgodot

解决方案


默认情况下,iOS 上的触摸有 150 毫秒的延迟(但在 Android 上没有)。这是由操作系统出于各种原因强加的,但您可以在项目设置( )中减小此值input_devices/pointing/ios/touch_delay并再次将项目导出到 iOS。

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


推荐阅读