godot study

184 阅读2分钟
  1. scene 被保存为文件,xxx.tscn (text scene)

    • 这些文件 xxx.tscn 保存的内容,为 scene 的压缩内容,也就是 Packed Scenes
  2. instance 实例为 scene 的蓝图

  3. instance scene 类似node,

  4. 在实例化中,resource 资源是无法更改属性的,除非唯一化。唯一化之后,就可以更改属性。

  5. Resource 也是 godot 中很重要的一块

  6. godot 引擎与其他引擎的区别在于:

    • instances
    • scenes
  7. 每一个 GDScript 文件都代表一个 类。

    • extend 关键字标明 继承哪个类。
      • 这个脚本将会继承类的函数和属性
    • In GDScript, if you omit the line with the extends keyword, your class will implicitly extend RefCounted, which Godot uses to manage your application's memory.
  8. 在 inspector 栏中,属性名使用空格隔开的,但是代码中的使用,使用下划线隔开。通过将鼠标放在属性位置,可以知道在代码中如何引用。

  9. godot 中默认以 弧度(Angles) 为单位


  1. 创建 scene 时,最好使得 scene 没有对外部的依赖。如果对外部必须有依赖,

  1. scene 的根节点应该选择什么样的根节点呢?

    • 该根节点能表现出 scene 需要的功能
  2. 在 Godot 中,类的命名格式推荐使用 驼峰式, 函数,或者变量命名,推荐使用 蛇形命名法

  3. $ 符号 与 get_node 函数一样的功能

  4. The delta parameter in the _process() function refers to the frame length - the amount of time that the previous frame took to complete.Using this value ensures that your movement will remain consistent even if the frame rate changes.

  5. Using set_deferred() tells Godot to wait to disable the shape until it's safe to do so.


节点:

  1. Area2D : 本身具有 collision 和 NODE2D 的功能

    • Area2D detect objects that overlap or run into the player
    • 通过添加子节点,可以扩展功能
  2. AnimatedSprite2D

    • 通过包含 多个 textures 作为 每一帧,从而展现出动画
    • 与 Sprite2D 的区别:他不能将携带的多个 texture 作为动画
    • 该节点使用 SpriteFrames 作为资源类型,保存 frames 或者 animation data
  3. CollisionShape2D

    • 提供 detection shape
    • shape2d 类型,保存包裹类型
  4. RigidBody2D

    • 由物理仿真进行移动
  5. VisibleOnScreenNotifier2D

    • 检测 节点是否不在视野内
  6. Marker2D

    • 用于编辑的通用 2D 位置提示。类似于普通的 Node2D,但它始终在 2D 编辑器中显示十字。该节点处于选中状态时,可以使用 2D 编辑器中的小工具来设置十字的视觉大小
  7. Path2D

    • 包含一个 Curve2D 路径,供 PathFollow2D 节点遵循。
      • PathFollow2D 节点: 对 Path2D 的点取样的取样器。