Drag and drop works
This commit is contained in:
72
Letter.cs
72
Letter.cs
@@ -1,44 +1,52 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public class Letter : AnimatedSprite
|
||||
namespace lettergodot
|
||||
{
|
||||
private string letter = "A";
|
||||
private Label label;
|
||||
|
||||
public string Value
|
||||
|
||||
public class Letter : AnimatedSprite
|
||||
{
|
||||
get { return letter; }
|
||||
set
|
||||
private string letter = "A";
|
||||
private Label label;
|
||||
|
||||
public string Value
|
||||
{
|
||||
letter = value;
|
||||
UpdateLetter();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user