Godot4开发2D游戏,GDScript控制人物移动

preview
共298个文件
cache:236个
cfg:22个
node:5个
需积分: 0 19 下载量 184 浏览量 更新于2024-01-25 收藏 6.26MB ZIP 举报
Godot4开发2D游戏自学手册,第五节代码,用GDScript控制人物移动。extends CharacterBody2D enum { WALK, SWORD } var state = WALK const SPEED = 300.0 func _physics_process(delta): match state: WALK: walk_state() SWORD: sword_state() move_and_slide() func walk_state(): var direction = Vector2.ZERO direction.x = Input.get_axis("left", "right") direction.y = Input.get_axis("up", "down") if direction: velocity = direction * SPEED else: velocity= Vector2.ZERO func sword_state(): pass
游戏自学
  • 粉丝: 1609
  • 资源: 44
上传资源 快速赚钱
voice
center-task 前往需求广场,查看用户热搜

最新资源