Add new components: CannotStompComponent, SkillUnlockedComponent, SpaceshipEnterComponent, SpaceshipExitComponent, SpinComponent, StompDamageComponent, StraightMotionComponent, TerrainHitFx, TooltipComponent, TrailComponent, and UnlockOnRequirementComponent
This commit is contained in:
39
scripts/components/TooltipComponent.cs
Normal file
39
scripts/components/TooltipComponent.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Godot;
|
||||
|
||||
namespace Mr.BrickAdventures.scripts.components;
|
||||
|
||||
public partial class TooltipComponent : Node
|
||||
{
|
||||
[Export] public Area2D Area { get; set; }
|
||||
[Export] public Control UiRoot { get; set; }
|
||||
[Export] public string Text { get; set; } = string.Empty;
|
||||
[Export] public Label TooltipLabel { get; set; }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
TooltipLabel.Text = Text;
|
||||
UiRoot.Visible = false;
|
||||
Area.BodyEntered += OnBodyEntered;
|
||||
Area.BodyExited += OnBodyExited;
|
||||
}
|
||||
|
||||
private void OnBodyEntered(Node2D body)
|
||||
{
|
||||
ShowTooltip();
|
||||
}
|
||||
|
||||
private void OnBodyExited(Node2D body)
|
||||
{
|
||||
HideTooltip();
|
||||
}
|
||||
|
||||
private void ShowTooltip()
|
||||
{
|
||||
UiRoot.Visible = true;
|
||||
}
|
||||
|
||||
private void HideTooltip()
|
||||
{
|
||||
UiRoot.Visible = false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user