Skip to main content

Jeremy's Variety Hour

Broadside, Update #1 – Menus and Scenes (and files)

kennebel
Published on 2024-12-11

Table of Contents

  • Overview
  • UI’s
  • Resources
  • Bonus: Godot File/Folder management
  • Links

Overview

This update session, I worked on building a rudimentary user interface, and looked at how to switch between scenes. I also learned about the option to have Godot ignore a folder, so you can put files in the project, that won’t be a part of the development process.

UI’s

The Godot Engine combines a 2D rendering engine with a 3D rendering engine. By adding a “CanvasLayer” object in your 3D scene hierarchy (renamed to TopMenu here), you can add UI controls, manage their placement, and wire them up for actions. In this case, I used a “VBoxContainer”, which by default auto sizes based on content, and lays out each control vertically, in the order it is listed in the hierarchy.

When you place a control, like the VBoxContainer, you will notice in the inspector, Layout Section, that there is a notification/warning message: “This node doesn’t have a control parent”. All this means is that the placement is entirely on the settings you provide, rather than inheriting the location, anchors, and all that. This will not impact the functionality of the control at all. It is safe to ignore that and move on if you know it is supposed to not have a parent Control managing it.

For the scene with the ships, i used the HBoxContainer to easily place the buttons horizontally along the top.

With the buttons set up, I was able to switch between scenes easily!

Resources

https://docs.godotengine.org/en/stable/tutorials/scripting/resources.html

A resource file is a way to have data accessible to Godot scripts, while avoiding the usual problems of data storage and ORM issues. This allows you to create a class to store data, have the system save the information directly from the class. I have set one up, but haven’t tried to save/reload data over multiple sessions yet.

Bonus: Godot File/Folder management

In the documentation, there is a section called Project organization, which covers some basic folder strategies. More importantly, it mentions the fact that if you add an empty file called “.gdignore”, the Godot Editor will ignore that folder. This means that it will not show up in the Editor UI, and it will not try to “import” anything in that folder. Since I created a folder to save progress screenshots, and they were being brought in to the game unnecessarily, this was a great find. 🙂

Links

Categories:

Leave a Reply

Your email address will not be published. Required fields are marked *