Back to "Introduction to Godot 4" Course
Part 2: Creating Your First 2D Scene
Welcome back! In Part 1, we installed Godot 4. Now, let’s dive into creating our first scene.
Advertisement Placeholder
This is where your high-revenue AdSense units will appear.
Understanding Nodes and Scenes
Godot uses a unique architecture:
- A Node is the smallest building block. It can be a sprite, a sound, or a physics body.
- A Scene is a collection of Nodes organized in a tree.
Creating the Main Scene
- In the top-left Scene dock, click 2D Scene. This creates a generic
Node2Das the root. - Rename this node to
World. - Save the scene by pressing
Ctrl + S. Name itworld.tscn.
Adding a Sprite
Every game needs visuals!
- Right-click the
Worldnode and select Add Child Node. - Search for
Sprite2Dand add it. - In the Inspector on the right, look for the
Textureproperty. Drag the defaulticon.svgfrom the FileSystem dock into the Texture slot.
Congratulations! You have just created a scene and added a visual element to your game.
Writing the Movement Script
Let’s write a small script to make it move. We’ll start breaking down the logic starting from line 12:
|
|
Next time, we’ll dive deeper into more advanced GDScript logic.
Advertisement Placeholder
This is where your high-revenue AdSense units will appear.
On this page
Advertisement Placeholder
