From a001fc12669b2f421bc12dc19cefec434c2456f2 Mon Sep 17 00:00:00 2001 From: sebashtioon Date: Wed, 6 Nov 2024 16:51:00 +1100 Subject: [PATCH] (#23) Make the inventory object, when dragging it, display on top of others. --- .../Player/Inventory/InventoryDropable.tscn | 18 ++++++++++++++++++ .../Inventory/InventoryDropable_SCRIPT.gd | 7 +++++++ 2 files changed, 25 insertions(+) diff --git a/Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable.tscn b/Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable.tscn index e863cf98..8db85d20 100644 --- a/Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable.tscn +++ b/Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable.tscn @@ -40,6 +40,24 @@ text = "ITEM_TYPE" horizontal_alignment = 1 vertical_alignment = 1 +[node name="z_index" type="Label" parent="."] +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -39.0 +offset_top = -69.5 +offset_right = 39.0 +offset_bottom = -46.5 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("2_qromc") +theme_override_font_sizes/font_size = 10 +text = "z_index = 0" +horizontal_alignment = 1 +vertical_alignment = 1 + [connection signal="area_entered" from="Area2D" to="." method="_on_area_2d_area_entered"] [connection signal="area_exited" from="Area2D" to="." method="_on_area_2d_area_exited"] [connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"] diff --git a/Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable_SCRIPT.gd b/Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable_SCRIPT.gd index 558bba5a..ccadce71 100644 --- a/Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable_SCRIPT.gd +++ b/Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable_SCRIPT.gd @@ -14,6 +14,7 @@ var can_create_pickup = true @onready var mouse_over_timer = $MouseOverTimer func _ready(): + self.z_index = 0 $ITEM_TYPE.text = ITEM_TYPE.capitalize() if "REDFLOWER" in ITEM_TYPE: $ITEM_TYPE.text = "Red Flower" @@ -31,6 +32,10 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): + # debugging + $z_index.text = str(self.z_index) + + if debounce_timer > 0: debounce_timer -= delta else: @@ -41,6 +46,7 @@ func _process(delta): if mouse_over_timer.time_left == 0: initialPos = global_position InventoryManager.is_dragging = true + self.z_index = 10 InventoryManager.item_ref = ITEM_TYPE if Input.is_action_pressed("inventory_click") and InventoryManager.is_dragging: global_position = get_global_mouse_position() @@ -55,6 +61,7 @@ func _process(delta): else: InventoryManager.is_dragging = false # debugging + self.z_index = 0 var slotNumber = slot[4] var debug_slot_number_label = get_node("/root/World/Player/Head/Camera3D/InventoryLayer/debug_slot_info") debug_slot_number_label.text = "You just released on slot number: " + slotNumber