41 lines
1.0 KiB
C#
41 lines
1.0 KiB
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, string animation = "transit", float waitSecond = 0)
|
|
{
|
|
GameManager.NextScene = nextScene;
|
|
var ap = GetNode<AnimationPlayer>("AnimationPlayer");
|
|
Layer = 9999;
|
|
Show();
|
|
ap.Play(animation);
|
|
await ToSignal(ap, AnimationMixer.SignalName.AnimationFinished);
|
|
if (waitSecond > 0) {
|
|
await ToSignal(GetTree().CreateTimer(waitSecond), SceneTreeTimer.SignalName.Timeout);
|
|
}
|
|
if (needLoadResources) {
|
|
GetTree().ChangeSceneToFile("res://loader.tscn");
|
|
} else {
|
|
GetTree().ChangeSceneToFile(nextScene);
|
|
}
|
|
ap.PlayBackwards(animation);
|
|
await ToSignal(ap, AnimationMixer.SignalName.AnimationFinished);
|
|
Layer = -1;
|
|
Hide();
|
|
}
|
|
|
|
}
|