From 54383819d959ca4a59972ee1a25c1b69cd9f4150 Mon Sep 17 00:00:00 2001 From: cakipaul Date: Wed, 30 Jul 2025 21:23:47 +0800 Subject: [PATCH] notification kill privous tween --- scene/notification/notification.gd | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scene/notification/notification.gd b/scene/notification/notification.gd index d401d33c..a6462d06 100644 --- a/scene/notification/notification.gd +++ b/scene/notification/notification.gd @@ -38,15 +38,18 @@ func show_center_texture(texture, duration := 3.0): tween.tween_interval(max(0.1, duration - 0.8)) tween.tween_property(center_texture, "modulate:a", 0, 0.4) +var center_notification_tween: Tween func show_center_notification(msg, duration := 3.0): if not top_center_label: return top_center_label.text = msg - var tween = create_tween() - tween.tween_property(top_center_label, "modulate:a", 1, 0.4) - tween.tween_interval(max(0.1, duration - 0.8)) - tween.tween_property(top_center_label, "modulate:a", 0, 0.4) + if center_notification_tween and center_notification_tween.is_running(): + center_notification_tween.kill() + center_notification_tween = create_tween() + center_notification_tween.tween_property(top_center_label, "modulate:a", 1, 0.4) + center_notification_tween.tween_interval(max(0.1, duration - 0.8)) + center_notification_tween.tween_property(top_center_label, "modulate:a", 0, 0.4) func show_notification(msg, number):