42 lines
958 B
GDScript
42 lines
958 B
GDScript
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:
|
|
area2d.collision_mask = 5 # 1 + 4
|
|
area2d.monitoring = true
|
|
area2d.body_entered.connect(_on_body_entered, CONNECT_ONE_SHOT)
|
|
|
|
|
|
func _on_animation_finished() -> void:
|
|
if next_animation != "":
|
|
play(next_animation)
|
|
|
|
|
|
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:
|
|
modulate.a = 0
|
|
var tween = create_tween()
|
|
# 透明度逐渐变为 1
|
|
tween.tween_property(self, "modulate:a", 1.0, 2.5)
|
|
# 播放动画
|
|
# light_mask = 17
|
|
play(animation)
|