1bit-game-jam/scripts/Menu.cs
2023-08-19 12:28:56 +03:00

33 lines
757 B
C#

using Godot;
public partial class Menu : Node2D
{
private Timer _timer;
private AudioStreamPlayer2D _thunderclap;
private AnimationPlayer _animationPlayer;
public override void _Ready()
{
_timer = (Timer)FindChild("Timer");
_thunderclap = (AudioStreamPlayer2D)FindChild("Thunderclap");
_animationPlayer = (AnimationPlayer)FindChild("AnimationPlayer");
GameManager.IsPlaying = false;
_animationPlayer.Play("intro_animation");
}
public override void _Input(InputEvent @event)
{
if (@event.IsActionPressed("ui_confirm") && _timer.IsStopped())
{
_animationPlayer.Play("thunder");
_thunderclap.Play();
_timer.Start();
}
}
public void ChangeScene()
{
GetTree().ChangeSceneToFile("res://scenes/main_scene.tscn");
}
}