《迷失岛2》游戏框架开发01:实现场景转换|Godot教程

Godot学习笔记
# 3.x的export(String,FILE,"*.tscn")换成4.x的@export_file("*.tscn")
@export_file("*.tscn") var target_path: String
func _interact():
# godot3.x中【.父类函数】 换成4.x的 【supser.父类函数】
super._interact()
# godot3.x中change_scene换成4.x的change_scene_to_file
get_tree().change_scene_to_file(target_path)
func change_scene(path: String):
var tween := get_tree().create_tween()
tween.tween_callback(color_rect.show)
tween.tween_property(color_rect,"color:a",1.0,0.2)
tween.tween_callback(get_tree().change_scene_to_file.bind(path))
tween.tween_property(color_rect,"color:a",0.0,0.3)
tween.tween_callback(color_rect.hide)
extends Interactable
class_name Teleporter
# 3.x的export(String,FILE,"*.tscn")换成4.x的@export_file("*.tscn")
@export_file("*.tscn") var target_path: String
func _interact():
# godot3.x中[.父类函数] 换成4.x的 [supser.父类函数]
super._interact()
# godot3.x中change_scene换成4.x的change_scene_to_file
SceneChanger.change_scene(target_path)