diff --git a/scripts/notification_display.gd b/scripts/notification_display.gd index 17fa3ff..8e5a713 100644 --- a/scripts/notification_display.gd +++ b/scripts/notification_display.gd @@ -32,14 +32,42 @@ func show_notification(weapon_name: String, player_node: Node2D, player_sprite_s # Use container's natural width, but fix height at 16px size = Vector2(_container.size.x, 16.0) - # Position using origin offset for Y, to the right of player for X + # Calculate target position _update_position() - modulate.a = 1.0 + var target_pos = position - # Fade out and free - var tween = create_tween() - tween.tween_property(self, "modulate:a", 0.0, 2.0) - tween.tween_callback(_on_fade_complete) + # Start 10px above destination, fully transparent + position.y = target_pos.y - 10.0 + modulate.a = 0.0 + + # Pause following during fade-in so the tween isn't overridden by _process + _follow_player = false + + # Fade in and slide into position with overshoot + var tween = create_tween().set_parallel() + tween.tween_property(self, "modulate:a", 1.0, 0.3) + var move_tween = tween.tween_property(self, "position:y", target_pos.y, 0.3) + move_tween.set_trans(Tween.TRANS_ELASTIC).set_ease(Tween.EASE_OUT) + + # Wait for fade-in to finish, then resume following + await tween.finished + _follow_player = true + + # Stay fully visible for a moment before fading + await get_tree().create_timer(0.35).timeout + + # Record current position as the fade-out starting point + await get_tree().process_frame + var fade_start_y = position.y + + # Fade out and drift downward with steady acceleration + _follow_player = false + var fade_out = create_tween().set_parallel() + fade_out.tween_property(self, "modulate:a", 0.0, .35) + var drift = fade_out.tween_property(self, "position:y", fade_start_y + 7, .3) + drift.set_trans(Tween.TRANS_QUAD).set_ease(Tween.EASE_IN) + await fade_out.finished + queue_free() func _process(_delta: float) -> void: @@ -82,8 +110,3 @@ func _update_position() -> void: notif_y = clamp(notif_y, 0, viewport_size.y - size.y) position = Vector2(notif_x, notif_y) - - -func _on_fade_complete() -> void: - _follow_player = false - queue_free()