创建新场景

  • 创建一个新的节点–TileMapLayer类型
    • 从网站下载 grass-01 素材
    • 创建新tileset,并设置宽高为32px
    • 在ordering中将zIndex设置为-1,设置为背景
    • 将图片拖入TileSet中,在下方控制台中
    • 在TileMapLayer节点中新增一个PhysicsLayer,collision为5(表示在第五层)
    • 在TileSet中Paint选项中的PhysicsLayer中绘制所需的物理层图案
    • 将Player的CollisionLayer的Mask层选中为5,表示与第五层的物理层产生碰撞
    • 创建地形Terrain Set,添加一个Terrain
    • 在用户节点下添加一个Camera2D节点
    • 将Player的Motion Mode改为float,角度改为10
    • 修改Player节点脚本中的_process代码
      1
      2
      3
      4
      5
      6
      7
      8
      func _process(_delta: float) -> void:
      #direction.x = Input.get_action_strength("right") - Input.get_action_strength("left")
      #direction.y = Input.get_action_strength("down") - Input.get_action_strength("up")
      direction = Vector2(
      Input.get_axis("left", "right"),
      Input.get_axis("up", "down")
      ).normalized()
      pass