Skip to content

Commit

Permalink
(#23) Make the inventory object, when dragging it, display on top of …
Browse files Browse the repository at this point in the history
…others.
  • Loading branch information
sebashtioon committed Nov 6, 2024
1 parent 9dcffa1 commit a001fc1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Scenes and Scripts/Scenes/Player/Inventory/InventoryDropable.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand All @@ -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()
Expand All @@ -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
Expand Down

0 comments on commit a001fc1

Please sign in to comment.