Added flying beet to the ui when used

This commit is contained in:
jonathan
2025-12-16 18:56:18 +01:00
parent fef8380a57
commit 7310bfbf6e
15 changed files with 114 additions and 18 deletions
@@ -0,0 +1,28 @@
using System;
using Godot;
namespace Babushka.scripts.CSharp.Common.Fight;
public partial class FlyingIndicator : Node2D
{
[Export] private Label _label = null!;
[Export] private TextureRect _sprite = null!;
public void Initialize(string? text = null, Texture2D? icon = null)
{
_label.Visible = text != null;
_sprite.Visible = icon != null;
if (text != null) _label.Text = text;
if (icon != null) _sprite.Texture = icon;
var tween = CreateTween();
var xMovement = GD.RandRange(-150, 150);
var yMovement = GD.RandRange(-400, -250);
tween.Parallel().TweenProperty(this, "position:x", xMovement, .6);
tween.Parallel().TweenProperty(this, "position:y", yMovement, .6)
.SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Quad);
tween.Chain().TweenCallback(Callable.From(QueueFree));
}
}