-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWLabel.cs
More file actions
27 lines (22 loc) · 768 Bytes
/
Copy pathWLabel.cs
File metadata and controls
27 lines (22 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using Godot;
using System;
public class WLabel : Label
{
// holds a reference to a button
private readonly WButton WButton;
public override void _PhysicsProcess(float delta)
{
// sets our text to the amount of units purchased
Text = $"{WButton.UnitName}: {WButton.NumUnits}";
}
// no argument constructor, just in case the editor expects this
public WLabel() : this(null) { }
// basic constructor for this custom label
public WLabel(WButton wbutton) : base()
{
this.WButton = wbutton;
Vector2 LabelPos = new Vector2(WButton.GetPosition().x, (WButton.GetPosition().y + WButton.GetSize().y + 2f));
this.SetPosition(LabelPos);
this.SetSize(new Vector2(0f, 14f));
}
}