整理了一下文件位置

This commit is contained in:
2025-02-02 09:44:09 +08:00
parent 532c55e2a3
commit 7fdd7adc47
8 changed files with 177 additions and 167 deletions

22
components/ToastShow.gd Normal file
View File

@@ -0,0 +1,22 @@
extends PanelContainer
@onready var label = $Label
var display_time = 4.0 # 显示的时间(秒)
var fade_duration = 1.0 # 渐隐时间(秒)
func Toast(text: String, text_color: Color = Color.WHITE):
label.text = text
label.modulate = text_color
show()
modulate.a = 1 # 确保初始透明度为 1
await get_tree().create_timer(display_time).timeout # 等待显示时间
await fade_out() # 开始渐隐
func fade_out() -> void:
var fade_step = 1.0 / (fade_duration / 60) # 每帧减少的透明度
while modulate.a > 0:
modulate.a -= fade_step
if modulate.a < 0:
modulate.a = 0
await get_tree().create_timer(0).timeout # 等待下一帧
hide() # 完全透明时隐藏面板

16
components/ToastShow.tscn Normal file
View File

@@ -0,0 +1,16 @@
[gd_scene load_steps=2 format=3 uid="uid://ffw2vjwnwvew"]
[ext_resource type="Script" path="res://components/ToastShow.gd" id="1_0rpwy"]
[node name="ToastShow" type="PanelContainer"]
offset_left = 469.0
offset_top = 557.0
offset_right = 533.0
offset_bottom = 580.0
size_flags_horizontal = 6
size_flags_vertical = 4
script = ExtResource("1_0rpwy")
[node name="Label" type="Label" parent="."]
layout_mode = 2
text = "提示弹窗"