首先创建一个名为 Node 2d 命名为Stage ONE
创建一个名为 KinemeaticBody 2D 命名为Player的节点
添加脚本Sprite 赋予人物材质,导入选择pixel 2d 重新导入使其画面不模糊
在Player节点也就是( KinemeaticBody 2D)里面写脚本文件
将Player节点保存,并且添加到SteageOne场景中区 run 游戏
xtends KinematicBody2D
var velocity = Vector2()
func _physics_process(delta):
if Input.is_action_pressed("ui_right"):
velocity.x = 100
elif Input.is_action_pressed("ui_left"):
velocity.x =-200
else:
velocity.x=0
if Input.is_action_pressed("ui_up"):
velocity.y = -100
elif Input.is_action_pressed("ui_down"):
velocity.y=100
else:
velocity.y=0
move_and_slide(velocity)
![](https://img.haomeiwen.com/i13794540/a3a42c9eb4572a6c.png)
![](https://img.haomeiwen.com/i13794540/7a2d7a19fef8f3a1.png)
![](https://img.haomeiwen.com/i13794540/2772c15ebc843acd.png)
网友评论