fix: make inventory backpack visible by instancing in Game.tscn and fixing Tween API
- Add InventoryBackpack under HUD CanvasLayer (layer 5) in Game.tscn - Add InventoryOverlay under InventoryOverlayLayer CanvasLayer (layer 10) - Fix Tween.TRANS_SINE_IN -> .set_trans(TRANS_SINE).set_ease(EASE_IN) in InventoryBackpack.gd (Godot 4.6 split transition and easing APIs)
This commit is contained in:
21
Game.tscn
21
Game.tscn
@@ -10,6 +10,8 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://c0mp4a2u3jkd" path="res://portrait.tscn" id="7_fj12q"]
|
[ext_resource type="PackedScene" uid="uid://c0mp4a2u3jkd" path="res://portrait.tscn" id="7_fj12q"]
|
||||||
[ext_resource type="Script" uid="uid://bsvab128vy1ip" path="res://OffsetCameraBasedOnMovement.gd" id="8_cvftx"]
|
[ext_resource type="Script" uid="uid://bsvab128vy1ip" path="res://OffsetCameraBasedOnMovement.gd" id="8_cvftx"]
|
||||||
[ext_resource type="PackedScene" uid="uid://dyk4rcqsk3aed" path="res://scenes/kq4_003_fountain_pool/kq4_003_fountain_pool.tscn" id="8_yx171"]
|
[ext_resource type="PackedScene" uid="uid://dyk4rcqsk3aed" path="res://scenes/kq4_003_fountain_pool/kq4_003_fountain_pool.tscn" id="8_yx171"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dxkyfas46q7ef" path="res://inventory/inventory_backpack/InventoryBackpack.tscn" id="9_backpack"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://djoycn4xfa8p3" path="res://inventory/inventory_overlay/InventoryOverlay.tscn" id="a_overlay"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_44mjr"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_44mjr"]
|
||||||
shader = ExtResource("2_jr51a")
|
shader = ExtResource("2_jr51a")
|
||||||
@@ -183,3 +185,22 @@ label_settings = SubResource("LabelSettings_narrator")
|
|||||||
horizontal_alignment = 1
|
horizontal_alignment = 1
|
||||||
vertical_alignment = 1
|
vertical_alignment = 1
|
||||||
autowrap_mode = 3
|
autowrap_mode = 3
|
||||||
|
|
||||||
|
[node name="HUD" type="CanvasLayer" parent="." unique_id=-294967295]
|
||||||
|
layer = 5
|
||||||
|
|
||||||
|
[node name="InventoryBackpack" parent="HUD" unique_id=-294967294 instance=ExtResource("9_backpack")]
|
||||||
|
anchors_preset = 12
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -64.65503
|
||||||
|
offset_bottom = -4.654907
|
||||||
|
grow_vertical = 0
|
||||||
|
|
||||||
|
[node name="InventoryOverlayLayer" type="CanvasLayer" parent="." unique_id=-294967293]
|
||||||
|
layer = 10
|
||||||
|
visible = false
|
||||||
|
|
||||||
|
[node name="InventoryOverlay" parent="InventoryOverlayLayer" unique_id=-294967292 instance=ExtResource("a_overlay")]
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func _transition_to_idle() -> void:
|
|||||||
_active_tween = tween
|
_active_tween = tween
|
||||||
_animating = true
|
_animating = true
|
||||||
tween.tween_property(backpack_icon, "rotation", 0.0, 0.35).set_trans(Tween.TRANS_LINEAR)
|
tween.tween_property(backpack_icon, "rotation", 0.0, 0.35).set_trans(Tween.TRANS_LINEAR)
|
||||||
tween.tween_property(backpack_icon, "position", backpack_icon.position, 0.35).set_trans(Tween.TRANS_SINE_IN)
|
tween.tween_property(backpack_icon, "position", backpack_icon.position, 0.35).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
|
||||||
tween.tween_callback(_on_transition_complete).bind(State.IDLE)
|
tween.tween_callback(_on_transition_complete).bind(State.IDLE)
|
||||||
|
|
||||||
func _transition_to_open() -> void:
|
func _transition_to_open() -> void:
|
||||||
@@ -87,7 +87,7 @@ func _transition_to_open() -> void:
|
|||||||
_active_tween = tween
|
_active_tween = tween
|
||||||
_animating = true
|
_animating = true
|
||||||
tween.tween_property(backpack_icon, "rotation", PI / 4, 0.35).set_trans(Tween.TRANS_LINEAR)
|
tween.tween_property(backpack_icon, "rotation", PI / 4, 0.35).set_trans(Tween.TRANS_LINEAR)
|
||||||
tween.tween_property(backpack_icon, "position", Vector2(backpack_icon.position.x + 20, backpack_icon.position.y + 20), 0.35).set_trans(Tween.TRANS_SINE_IN)
|
tween.tween_property(backpack_icon, "position", Vector2(backpack_icon.position.x + 20, backpack_icon.position.y + 20), 0.35).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
|
||||||
tween.tween_callback(_on_transition_complete).bind(State.OPEN)
|
tween.tween_callback(_on_transition_complete).bind(State.OPEN)
|
||||||
tween.tween_callback(overlay_show_requested.emit)
|
tween.tween_callback(overlay_show_requested.emit)
|
||||||
|
|
||||||
@@ -222,7 +222,9 @@ func _on_inventory_changed() -> void:
|
|||||||
_update_floating_item()
|
_update_floating_item()
|
||||||
|
|
||||||
func _gui_input(event: InputEvent) -> void:
|
func _gui_input(event: InputEvent) -> void:
|
||||||
|
|
||||||
if event is InputEventMouseButton and event.pressed and event.button_index == 1:
|
if event is InputEventMouseButton and event.pressed and event.button_index == 1:
|
||||||
|
print("OBTAINED")
|
||||||
if _state == State.IDLE:
|
if _state == State.IDLE:
|
||||||
transition_to(State.OPEN)
|
transition_to(State.OPEN)
|
||||||
elif _state == State.OPEN:
|
elif _state == State.OPEN:
|
||||||
|
|||||||
Reference in New Issue
Block a user