supervisor-simulator/scripts/SceneTransit.cs
2024-11-29 22:56:50 +08:00

38 lines
890 B
C#

using Godot;
using System;
public partial class SceneTransit : CanvasLayer
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
Layer = -1;
Hide();
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public async void Transit(string nextScene, bool needLoadResources = true)
{
GameManager.NextScene = nextScene;
var ap = GetNode<AnimationPlayer>("AnimationPlayer");
Layer = 9999;
Show();
ap.Play("transit");
await ToSignal(ap, AnimationMixer.SignalName.AnimationFinished);
if (needLoadResources) {
GetTree().ChangeSceneToFile("res://loader.tscn");
} else {
GetTree().ChangeSceneToFile(nextScene);
}
ap.PlayBackwards("transit");
await ToSignal(ap, AnimationMixer.SignalName.AnimationFinished);
Layer = -1;
Hide();
}
}