counter +1
This commit is contained in:
parent
0d0e16afa2
commit
92ebb2868d
11 changed files with 50 additions and 39 deletions
|
|
@ -1,12 +1,32 @@
|
|||
using System.Globalization;
|
||||
using Godot;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class SunCounter : Label
|
||||
public partial class SunCounter : Control
|
||||
{
|
||||
public override void _Process(double delta)
|
||||
public static SunCounter Instance { get; private set; }
|
||||
private Tween tween;
|
||||
[Export] private Label text;
|
||||
[Export] public TextureRect sunImage { get; private set;}
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Text = RuntimeLevelData.Instance.SunCount.ToString();
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public static void Update()
|
||||
{
|
||||
if (Instance.tween != null) Instance.tween.Kill();
|
||||
Instance.tween = Instance.CreateTween();
|
||||
Instance.tween.TweenMethod(Callable.From<int>(Instance.SetText), int.Parse(Instance.text.Text), RuntimeLevelData.Instance.SunCount, 1.0);
|
||||
}
|
||||
public static void UpdateInstantly()
|
||||
{
|
||||
Instance.text.Text = RuntimeLevelData.Instance.SunCount.ToString();
|
||||
}
|
||||
private void SetText(int value)
|
||||
{
|
||||
text.Text = value.ToString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue