fix: backpack icon returns to home position when overlay closes
This commit is contained in:
@@ -13,12 +13,14 @@ var _state: State = State.IDLE
|
|||||||
var _animating: bool = false
|
var _animating: bool = false
|
||||||
var _active_tween: Tween = null
|
var _active_tween: Tween = null
|
||||||
var _floating_item_color: Color = Color(1, 1, 1, 0)
|
var _floating_item_color: Color = Color(1, 1, 1, 0)
|
||||||
|
var _home_position: Vector2 = Vector2(0, 0)
|
||||||
|
|
||||||
@onready var backpack_icon: ColorRect = $BackpackIcon
|
@onready var backpack_icon: ColorRect = $BackpackIcon
|
||||||
@onready var floating_item: ColorRect = $FloatingItem
|
@onready var floating_item: ColorRect = $FloatingItem
|
||||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
_home_position = backpack_icon.position
|
||||||
floating_item.modulate = Color(1, 1, 1, 0)
|
floating_item.modulate = Color(1, 1, 1, 0)
|
||||||
floating_item.visible = false
|
floating_item.visible = false
|
||||||
InventoryManager.item_acquired.connect(_on_item_acquired)
|
InventoryManager.item_acquired.connect(_on_item_acquired)
|
||||||
@@ -71,7 +73,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).set_ease(Tween.EASE_IN)
|
tween.tween_property(backpack_icon, "position", _home_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 +89,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).set_ease(Tween.EASE_IN)
|
tween.tween_property(backpack_icon, "position", _home_position + Vector2(20, 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)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user