美文网首页
Godot网格移动笔记

Godot网格移动笔记

作者: 小沙盒工作室 | 来源:发表于2021-02-22 11:44 被阅读0次

1.需要将要移动的物体放在tileMap下面
JRPG Demo 按格子移动的总结
1.地图背景可以使用TileMap制作
2.玩家和敌人等非静态物体尽量不要放置在TileMap里面,会比较难处理代码
3.可以把玩家放在TileMap下面

由于TileMap和Node2D的坐标系不同,需要转换坐标系
TileMap的world_to_map()方法可以转换坐标,把世界坐标转换成TileMap坐标
善用macth方法,简化代码,不要写过多if
使用tween来过渡界面
ColorRect也可以过渡 (单色)
玩家移动
func get_input_direction():
return Vector2(
Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left"),
Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
)
更新方向
update_look_direction(direction):
$Pivot/Sprite.rotation = direction.angle()
善用枚举enmu减少代码量
enum默认从0开始 当自动排列的数字变量使用

相关文章

网友评论

      本文标题:Godot网格移动笔记

      本文链接:https://www.haomeiwen.com/subject/osvhfltx.html