đŸŽžī¸ Scenes and Nodes | Betabox

đŸŽžī¸ Scenes and Nodes

Nodes

Nodes are the building blocks of making a game! You can think of them as ingredients for your game. They can serve a variety of different purposes but they always have the following attributes:

  • A name
  • Editable properties
  • It can receive a callback every frame
  • Extendable
  • Can be a parent or a child

The last point means that every node can have children that are other nodes. This forms what we call a tree. This may be a little confusing right now but it will click when we start creating games! For now, just think of nodes as a way of organizing your game!

Scenes

A scene is a group of nodes that are organized in a tree. These scenes always have the following qualities:

  • Always have one root node
  • Can be saved to disk and loaded back
  • Can be instanced

Running a game in Godot means running the main scene. We can change between scenes as the game runs!

The Editor

Now let’s work on adding our first node! In the editor, you will notice a plus button in the top left of the scene dock. This button will allow us to add a node into our workspace. This button will always create the node as a child of the selected node unless there are no nodes, in which case, it will create the root node. For this exercise, we will click that button and then add a label node. It should look something like this:

../../_images/node_search_label.png

After clicking create, you should see your label node appear on screen! The next step will be to change the label node’s text property to say “Hello, World!” in the inspector.

../../_images/hw.png

Now you can click the Play Scene button which looks like this:

../../_images/playscene.png

You will be prompted to save the scene before you run it. Go ahead and do that now! After you save it, the scene will play and you should see a window pop up that says “Hello, World!”

Configuring the Project

As of right now, the only way to display your scene is to click the Play Scene button. This is because it has not been set as the main scene. Let’s do that now! To do this simply click Project in the main menu then select Project Settings. Once you have done that, we will set the main scene by doing the following:

../../_images/main_scene.png

This will now allow us to click the regular run button to start our game!