知识点: 松散耦合 题目: 在Godot中,为什么推荐场景应设计为具有松散耦合? 选项: A. 为了让场景更紧密地依赖于特定环境,提高集成度。✅ B. 为了减少场景文件的大小。✅ C. 为了提高场景的可重用性,并减少因修改一个类而对其他类产生负面影响的风险。✅ D. 为了强制所有场景都使用全局单例。✅
知识点:_get_configuration_warnings() 题目: 在Godot中,_get_configuration_warnings() 方法的主要用途是什么? 选项: A. 在运行时报告错误。✅ B. 在编辑器中为节点生成配置警告图标和提示信息,以表明其外部依赖或配置需求。✅ C. 自动修复场景中的配置问题。✅ D. 优化场景加载速度。✅
正确答案: B
原文依据: 「Returning a non-empty PackedStringArray from it will make the Scene dock generate a warning icon with the string(s) as a tooltip by the node. This is the same icon that appears for nodes such as the Area2D node when it has no child CollisionShape2D nodes defined.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)
知识点: 节点树结构 – 入口点 题目: 根据文档建议,一个游戏项目通常应该有一个明确的「入口点」,在Godot中这通常是什么? 选项: A. 一个名为 “Player” 的场景。✅ B. 一个自动加载的脚本。✅ C. 一个 “Main” 节点或主场景。✅ D. 第一个被创建的GUI元素。✅
正确答案: C
原文依据: 「A game should always have an “entry point”; somewhere you can definitively track where things begin so that you can follow the logic as it continues elsewhere. … In Godot, it’s a Main node.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)
知识点: 自动加载(Autoloads) 题目: 什么情况下应该创建一个自动加载(Autoload)的单例节点? 选项: A. 当你需要一个只在特定场景中使用的节点时。✅ B. 当你需要一个节点来管理玩家的视觉表现时。✅ C. 当系统需要跟踪全局可访问的内部数据,并且应该独立存在时。✅ D. 当你需要频繁地实例化和删除某个节点时。✅
正确答案: C
原文依据: 「If you have a system that… tracks all internal data, should be globally accessible, should be self-contained … then you should create an autoload ‘singleton’ node.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)
知识点:RemoteTransform / RemoteTransform2D 题目:RemoteTransform 和 RemoteTransform2D 节点的主要用途是什么? 选项: A. 在网络游戏中同步远程玩家的变换。✅ B. 允许一个节点有选择地继承另一个(可能不相关的)目标节点的变换元素。✅ C. 远程控制另一个计算机上的Godot实例。✅ D. 自动将2D变换转换为3D变换。✅
正确答案: B
原文依据: 「In some cases, you need these separated nodes to also position themselves relative to each other. You can use the RemoteTransform / RemoteTransform2D nodes for this purpose. They will allow a target node to conditionally inherit selected transform elements from the Remote* node.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)
知识点: OOP原则在场景设计中的应用 题目: 文档提到,脚本和场景作为引擎类的扩展,应该遵守OOP原则,例如SOLID、DRY、KISS、YAGNI。DRY原则指的是什么? 选项: A. Single Responsibility Principle (单一职责原则)✅ B. Don’t Repeat Yourself (不要重复你自己)✅ C. Keep It Simple, Stupid (保持简单愚蠢)✅ D. You Ain’t Gonna Need It (你不会需要它)✅
知识点: 场景交互:初始化Callable属性 题目: 通过初始化子节点的Callable属性来让父节点定义子节点的行为,这种方式的优点是什么? 选项: A. 子节点必须拥有该方法。✅ B. 比直接调用方法更不安全。✅ C. 比调用方法更安全,因为子节点不需要拥有这个方法的所有权。✅ D. 只能用于响应行为,不能启动行为。✅
知识点: 节点树结构:GUI管理 题目: 在进行场景切换(例如改变关卡)时,如果GUI节点不是自动加载的单例,可能会发生什么? 选项: A. GUI节点会自动适应新场景。✅ B. GUI节点会保持不变,显示在所有场景之上。✅ C. GUI节点可能会随着旧场景的卸载而被删除。✅ D. GUI节点会自动成为新场景的子节点。✅
正确答案: C
原文依据: 「Any GUI would also need to be either a singleton, a transitory part of the “World”, or manually added as a direct child of the root. Otherwise, the GUI nodes would also delete themselves during scene transitions.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)
知识点: 避免节点间的硬依赖 题目: 文档建议,兄弟节点(siblings)之间应该如何交互? 选项: A. 直接通过 ✅get_node("../SiblingName") 互相访问。 B. 通过一个共同的祖先节点(父节点或更高层级)来协调它们的通信和引用。✅ C. 将所有兄弟节点设为自动加载的单例。✅ D. 每个兄弟节点都应该复制一份对方的数据。✅
正确答案: B
原文依据: 「Although the examples above illustrate parent-child relationships, the same principles apply towards all object relations. Nodes which are siblings should only be aware of their own hierarchies while an ancestor mediates their communications and references.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)
知识点:top_level 属性 题目:CanvasItem 或 Node3D 节点的 top_level 属性的作用是什么? 选项: A. 将节点提升到场景树的根节点。✅ B. 使节点忽略其继承的变换(transform),其位置将相对于视口。✅ C. 确保节点总是在其他节点之上渲染。✅ D. 自动将节点设为自动加载。✅
知识点: 场景设计的首要目标 题目: 在设计场景时,如果可能,首要的设计目标是什么? 选项: A. 尽可能多地使用继承。✅ B. 使场景完全依赖于全局状态。✅ C. 设计场景使其没有外部依赖,即场景内部包含其所需的一切。✅ D. 将所有逻辑都放在一个巨大的主脚本中。✅
正确答案: C
原文依据: 「If at all possible, you should design scenes to have no dependencies. That is, you should create scenes that keep everything they need within themselves.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)
知识点: 场景组织中的父子关系判断 题目: 在决定一个节点是否应该是另一个节点的子节点时,一个关键的判断标准是什么? 选项: A. 它们在游戏世界中的物理位置是否接近。✅ B. 它们是否共享相同的脚本。✅ C. 移除父节点是否意味着子节点也应该被合理地移除。✅ D. 子节点是否需要频繁访问父节点的属性。✅
正确答案: C
原文依据: 「You should use parent-child relationships only in cases where nodes are effectively elements of their parents. Does removing the parent reasonably mean that the children should also be removed? If not, then it should have its own place in the hierarchy as a sibling or some other relation.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)
知识点: 匿名类型与命名类型(脚本与PackedScene) 题目: 文档中提到「匿名类型」和「命名类型」与场景组织有关,它们通常分别指什么? 选项: A. 匿名类型指没有脚本的节点,命名类型指有脚本的节点。✅ B. 匿名类型指通过 ✅new() 创建的节点实例,命名类型指场景编辑器中添加的节点。 C. 文档中讨论的是脚本(作为命名类型)和PackedScene(可以被视为匿名类型或蓝图)在性能和使用场景上的权衡。✅ D. 匿名类型指内置节点类型,命名类型指自定义节点类型。✅
知识点: 维护松散耦合的重要性 题目: 为什么在场景组织中,避免让子节点直接访问或了解其父节点或兄弟节点的内部结构非常重要? 选项: A. 因为这样可以提高编译速度。✅ B. 因为父节点和兄弟节点的内部结构是易变的,直接依赖会导致代码脆弱。✅ C. 因为子节点没有权限访问父节点或兄弟节点。✅ D. 因为这样可以减少内存使用。✅
正确答案: B
原文依据: 「Inevitably, changes may need to be made to a class, and if these changes cause it to interact with other scenes in unforeseen ways, then things will start to break down. The whole point of all this indirection is to avoid ending up in a situation where changing one class results in adversely affecting other classes dependent on it.」(出自:场景组织 — Godot Engine (4.x) 简体中文文档,N/A页)