xiandie/scene/ground/script/c02/火灾区域燃烧脚本.gd

42 lines
958 B
GDScript3
Raw Normal View History

extends AnimatedSprite2D
@export var fade_in: bool = false
@export var next_animation: String = ""
func _ready() -> void:
visible = false
frame = 0
# 结束后播放下一个动画
if next_animation != "":
animation_finished.connect(_on_animation_finished, CONNECT_ONE_SHOT)
sprite_frames.set_animation_loop(animation, false)
var area2d = $Area2D as Area2D
if area2d:
2025-05-14 20:43:55 +00:00
area2d.collision_mask = 5 # 1 + 4
area2d.monitoring = true
area2d.body_entered.connect(_on_body_entered, CONNECT_ONE_SHOT)
2025-05-14 20:43:55 +00:00
func _on_animation_finished() -> void:
if next_animation != "":
play(next_animation)
2025-05-14 20:43:55 +00:00
func recheck():
_on_body_entered()
func _on_body_entered(_node = null) -> void:
if not ArchiveManager.get_global_value("c02_burning"):
return
visible = true
if fade_in:
2025-05-30 11:05:06 +00:00
modulate.a = 0
var tween = create_tween()
# 透明度逐渐变为 1
2025-05-30 11:05:06 +00:00
tween.tween_property(self, "modulate:a", 1.0, 2.5)
# 播放动画
2025-06-04 11:46:27 +00:00
# light_mask = 17
2025-05-14 20:43:55 +00:00
play(animation)