如何在 GDScript 中通过向一个方向拖动来使 KinematicBody2D 移动?

问题描述

我想创建一个类似于这个(Slyway)的游戏,但是我对孩子的运动有问题,所以我不知道在抽奖过程中用什么来做运动。是InputEventScreenTouch还是InputEventScreenDrag,我想出来的就是这段代码不起作用

    extends KinematicBody2D

var veLocity = Vector2.ZERO
var direction = Vector2.ZERO
var speed = 200

func input(event):
    if event is InputEventScreenTouch:
        if event.ispressed():
            direction.x -= 1

func physicsprocess(delta):
    if veLocity.length() == 0:
    _input(event)
veLocity = Vector2.ZERO
veLocity += direction * speed
veLocity = moveand_slide (veLocity)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)