Files
old-coregodot/Letterbox.cs
2022-11-27 18:58:30 +01:00

29 lines
722 B
C#

using Godot;
using System;
public class Letterbox : Node2D
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
// assign random letters to all the child nodes of type Letter
foreach (var letter in GetChildren())
{
if (letter is Letter)
{
((Letter)letter).Value = RandomLetterAsAString();
}
}
}
// method that returns a string with a random capital letter inside
private string RandomLetterAsAString()
{
var random = new Random();
var randomLetter = (char)random.Next('A', 'Z' + 1);
return randomLetter.ToString();
}
}