Recap
回顾Instancing has many handy uses. At a glance, with instancing you have:
实例化有许多方便的用途。一目了然,通过实例化,您可以: - The ability to subdivide scenes and make them easier to manage.细分场景并使其更易于管理的能力。
- A tool to manage and edit multiple node instances at once.一次管理和编辑多个节点实例的工具。
- A way to organize and embed complex game flows or even UIs (in Godot, UI Elements are nodes, too).一种组织和嵌入复杂游戏流程甚至UI的方法(在Godot中,UI元素也是节点)。
Design language
设计语言But the greatest strength that comes with instancing scenes is that it works as an excellent design language. This distinguishes Godot from all the other engines out there. Godot was designed from the ground up around this concept.
但是,实例化场景所具有的最大优势在于,它是一种出色的设计语言。这将Godot与其他所有引擎区分开来。Godot是围绕这个概念从头开始设计的。 When making games with Godot, the recommended approach is to dismiss most common design patterns, such as MVC or Entity-Relationship diagrams, and instead think about your scenes in a more natural way. Start by imagining the visible elements in your game, the ones that can be named not just by a programmer, but by anyone.
使用Godot制作游戏时,建议的方法是消除最常见的设计模式,例如MVC或实体关系图,而以更自然的方式考虑场景。首先想象一下游戏中的可见元素,这些元素不仅可以被程序员命名,还可以被任何人命名。 For example, here's how a simple shooter game could be imagined:
例如,以下是一个简单的射击游戏的想象方式: You can come up with a diagram like this for almost any kind of game. Write down the parts of the game that you can visualize, and then add arrows to represent ownership of one component by another.
您可以为几乎所有类型的游戏设计出这样的图表。写下游戏中您可以可视化的部分,然后添加箭头以表示一个组件的所有权。 Once you have a diagram like this, the recommended process for making a game is to create a scene for each element listed in the diagram. You'll use instancing (either by code or directly in the editor) for the ownership relationships.
一旦有了这样的图表,推荐的制作游戏的过程就是为图表中列出的每个元素创建一个场景。您将通过实例化(通过代码或直接在编辑器中)用于所有权关系。 A lot of time spent in programming games (or software in general) is on designing an architecture and fitting game components to that architecture. Designing based on scenes replaces that approach and makes development much faster and more straightforward, allowing you to concentrate on the game logic itself. Because most game components map directly to a scene, using a design based on scene instantiation means little other architectural code is needed.
在对游戏(或一般而言的软件)进行编程时,要花费大量时间来设计体系结构并使游戏组件适合该体系结构。基于场景的设计取代了这种方法,使开发更快,更直接,使您可以专注于游戏逻辑本身。由于大多数游戏组件都直接映射到场景,因此使用基于场景实例化的设计意味着几乎不需要其他架构代码。 Let's take a look at one more, somewhat more complex, example of an open-world type game with lots of assets and nested elements:
让我们看一下一个开放世界类型的游戏的例子,该例子有点复杂,其中包含很多资产和嵌套元素: Take a look at the room element. Let's say we started there. We could make a couple of different room scenes, with different arrangements of furniture (also scenes) in them. Later, we could make a house scene, connecting rooms to make up its interior.
看看房间元素。假设我们从这里开始。我们可以制作几个不同的房间场景,并在其中布置不同的家具(也包括场景)。后来,我们可以制作房屋场景,将房间连接起来以构成其内部。 Then, we could make a citadel scene, which is made out of many instanced houses. Then, we could start working on the world map terrain, adding the citadel onto it.
然后,我们可以制作一个城堡场景,该场景由许多实例化的房屋组成。然后,我们可以开始在世界地图地形上进行工作,将城堡添加到其上。 Later, we could create scenes that represent guards (and other NPCs) and add them to the citadel as well. As a result, they would be indirectly added to the overall game world.
以后,我们可以创建代表守卫(和其他NPC)的场景,并将它们也添加到城堡中。结果,它们将被间接添加到整个游戏世界中。 With Godot, it's easy to iterate on your game like this, as all you need to do is create and instance more scenes. Furthermore, the editor UI is designed to be user friendly for programmers and non-programmers alike. A typical team development process can involve 2D or 3D artists, level designers, game designers, and animators, all working with the editor interface.
使用Godot,您可以像这样轻松地迭代游戏,因为您要做的就是创建并实例化更多场景。此外,编辑器UI旨在使程序员和非程序员都易于使用。典型的团队开发过程可能需要2D或3D艺术家,关卡设计师,游戏设计师和动画师,并且他们都需要使用编辑器界面。
Information overload!
信息过量!This has been a lot of high level information dropped on you all at once. However, the important part of this tutorial was to create an awareness of how scenes and instancing are used in real projects.
这是一次将大量高级信息提供给您的信息。但是,本教程的重要部分是使人们意识到在实际项目中如何使用场景和实例化。 Everything discussed here will become second nature to you once you start making games and putting these concepts into practice. For now, don't worry about it too much, and go on to the next tutorial!
一旦您开始制作游戏并将这些概念付诸实践,这里讨论的一切将成为您的第二天性。现在,不必太担心,继续下一个教程!
|