using Godot; using System; namespace lettergodot { public class Letter : AnimatedSprite { private string letter = "A"; private Label label; public string Value { get { return letter; } set { letter = value; UpdateLetter(); } } public override void _Ready() { // create label with a letter assigned as a text label = new Label(); label.Text = letter; // make label text bold and centered label.AddFontOverride("font", new DynamicFont() { FontData = new DynamicFontData() { FontPath = "res://Roboto-Bold.ttf" }, Size = 30 }); // make color of the text dark orange label.AddColorOverride("font_color", new Color(1, 0.5f, 0)); // make text centered in the sprite label.RectPosition = new Vector2(-10, -15); label.RectSize = new Vector2(64, 64); label.Align = Label.AlignEnum.Left; label.Valign = Label.VAlign.Top; // add label to the sprite AddChild(label); } private void UpdateLetter() { // update text of the label // to the letter assigned to the letter variable label.Text = letter; } } }