《迷失島2》游戲框架開發(fā)01:實(shí)現(xiàn)場(chǎng)景轉(zhuǎn)換|Godot教程

Godot學(xué)習(xí)筆記
# 3.x的export(String,FILE,"*.tscn")換成4.x的@export_file("*.tscn")
@export_file("*.tscn") var target_path: String
func _interact():
# godot3.x中【.父類函數(shù)】 換成4.x的 【supser.父類函數(shù)】
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中[.父類函數(shù)] 換成4.x的 [supser.父類函數(shù)]
super._interact()
# godot3.x中change_scene換成4.x的change_scene_to_file
SceneChanger.change_scene(target_path)