Changed UI sprites to use sprite in resource

This commit is contained in:
MaddoScientisto 2025-02-16 17:36:33 +01:00
commit f2482e4e38
10 changed files with 47 additions and 13 deletions

View file

@ -92,7 +92,12 @@ public partial class Hud : CanvasLayer
var hbox = new HBoxContainer();
_itemsContainer.AddChild(hbox);
var instance = item.HudItemScene.Instantiate<TextureRect>();
var instance = new TextureRect();
instance.Texture = item.InventorySprite;
instance.StretchMode = TextureRect.StretchModeEnum.Keep;
// change transform size?
//var instance = item.HudItemScene.Instantiate<TextureRect>();
//_in.CallDeferred("add_child", instance);
hbox.AddChild(instance);

View file

@ -348,11 +348,11 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
EmitSignal(nameof(InteractableAreaEntered), interactable);
if (_selector == null) return;
//_selector.Position = interactable.Position;
_selector.SelectedInteractable = interactable;
//_selector.AddInteractable(interactable);
//_selector.Visible = true;
//_lastInteractable = interactable;
_selector.AddInteractable(interactable);
//_selector.SelectedInteractable = interactable;
}
}

View file

@ -15,7 +15,7 @@ public partial class LootItem : Resource
[Export] public bool ConsumeOnUse;
[Export] public UiItemType UiType;
[Export] public AtlasTexture InventorySprite;
[Export] public Texture2D InventorySprite;
[Export] public SpriteFrames WorldSprite;
[Export] public PackedScene HudItemScene;

View file

@ -47,7 +47,15 @@ public partial class Selector : Node2D
if (Input.IsActionJustPressed("scan"))
{
SelectNext();
}
if (SelectedInteractable != null) {
this.Visible = true;
this.GlobalPosition = SelectedInteractable.GlobalPosition;
}
else
{
this.Visible = false;
}
}
@ -107,6 +115,7 @@ public partial class Selector : Node2D
public void UpdatePosition()
{
return;
if (SelectedInteractable != null)
{
this.Position = SelectedInteractable.Position;