What's New

Here are the most recent additions to the website. To find the latest for a specific category that you are interested in, just click on the "Categories" links on the right side of the screen. To get the Deluxe version of the article (a.k.a the version where the pretty pictures also show), click on the Article title to go to the Article's own page.


Hot Off the Press

The ItemList Node in Godot

Le Mon 02 July 2018

Download the pdf button

This article demonstrates using the ItemList Node in both Godot 2 and Godot 3. The ItemList node in Godot 3 has the ability to display the items in columns, but in this illustration we're just doing a basic single column list.

Using the ItemList Node

Using the ItemList Node is the same in both Godot 3 and Godot 2. In this example the ItemList node is loaded with the list components using code, and a button is used to take the selected item and display it in a label.

ItemList Demo in Action in Godot 3

Download the demonstration projects from here:

Scene Setup

The two examples differ slightly only in the Godot 3 version having an extra label with static text. Other than that they are the same.

ItemList Scene in Godot 2 Godot 2 version of the ItemList demonstration scene.

ItemList Scene in Godot 3
Godot 3 version of the ItemList demonstration scene.

The scene is comprised of;

  • a Panel for the root node,
  • a Button node (Renamed “GoButton”),
  • in the case of the Godot 2 example; a Label node. In the case of the Godot 3 examples it has the two Label nodes (called “Label-StaticNote” and “Label - output”),
  • and the ItemList node.

The Godot 3 ItemList has been set to “Single” which means only one item from the list can be selected. The alternative would allow multiple items to be selected.

The Panel, and the Labels are all using the default settings with the only changes being the Panel's Size which is set to match the project's window size (640x480) and the Label-StaticNote Text field which contains the phrase “You have Chosen:”

Similarly the Button is just a default button with the only change being the addition of “Go” to the Text field.

The Script

In order to make it all work, a script is required. This loads the items into the ItemList node and controls the query to the ItemList node when the button is pressed.

Attached to the Panel node is the following script:

extends Panel

var ItemListContent = ["We shall go this way","We shall go that way","which way shall we go?","I think we're lost"]

func _ready():
    #Load the ItemList by stepping through it and adding each item.
    for ItemID in range(4):

    get_node("ItemList").select(0,true) #This sets a default so we don't have
    # to do error catching if an empty selection is captured.

func ReportListItem():
    var ItemNo = get_node("ItemList").get_selected_items()

    #The output ItemNo is a list of selected items.  Use this to select
    #The matching component from the associated array, ItemListContent.

    var SelectedItemtext = ItemListContent[ItemNo[0]]
    get_node("Label - output").set_text(str(SelectedItemtext))

The script for the Godot 2 version is identical except for the name of the Label node used for displaying the selected item's text.

When the scene is run the ItemList node is loaded from the ItemListContent array. This is a done using a loop and the .add_item() method. To avoid problems with errors from empty selections, I have also set a default selection using the .select() method.

When the “GoButton” is pressed the script runs the “ReportListItem” function. This function gets the selected items from the ItemList node and returns the list of position value(s) of the selected item(s) in the list. We are only selecting one item so the list only has a single component. We use this to find the matching line of text in the ItemListContent array and use this to display in the Label. We also print the selected item array to the console.

It can be made a bit smarter with the application of Themes.

You can find an article on Spinboxes here: SpinBoxes in Godot3

Lire la suite - Read More …

Par Hamish Trolove, Catégorie : Tutorials

Tags : Godot / Graphics /

Recent Articles

SpinBoxes in Godot3

Le Thu 21 June 2018

I have been playing around with the Godot Game Engine recently to find a suitable alternative to the Blender Game Engine and to Pygame. It has been a rapid learning curve for me and I have a way to go yet. Having said that there are a few things I have learned that are probably worth sharing to spare others the same running around and experimentation I have needed to do in order to learn these things. So here is a brief article describing two ways to produce a SpinBox for interfaces made with Godot3.

Par Hamish Trolove, Catégorie : Tutorials

Tags : Godot / Graphics /

Lire la suite - Read More …

A Go-Motion Mine Trolley

Le Sun 27 May 2018

Yep. Yet another edition of the Mine Trolley. This time fitted with a motor and controller to run through a sequence of speeds and times.

Par Hamish Trolove, Catégorie : Tech Projects

Tags : Arduino / Electronics / 3D Printing / Art / Models / Sculpture / Stopmotion /

Lire la suite - Read More …

DC Motor Motion Sequence Controller

Le Fri 11 May 2018

This article describes a relatively simple motion controller for a small DC Motor. It was designed for a Go-Motion Mine Trolley based on my 3D printed stop-motion mine trolley model. The circuit makes use of an Arduino and its pulse width modulated (PWM) signal output to control the motor speed through a transistor. The Arduino sketch allows the user to dial up a range of different speed profiles for the sequence and select some pre-set timing programs to achieve the type of motion they have in mind.

Par Hamish Trolove, Catégorie : Tech Projects

Tags : Arduino / Electronics /

Lire la suite - Read More …