Pause
This commit is contained in:
parent
afd9e990f1
commit
30266b36cf
11 changed files with 253 additions and 22 deletions
11
scripts/components/gui/PauseButton.cs
Normal file
11
scripts/components/gui/PauseButton.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PauseButton : Button
|
||||
{
|
||||
public override void _Pressed()
|
||||
{
|
||||
PauseMenu.Pause();
|
||||
}
|
||||
|
||||
}
|
||||
1
scripts/components/gui/PauseButton.cs.uid
Normal file
1
scripts/components/gui/PauseButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cmfhiun6yrlr6
|
||||
32
scripts/components/gui/PauseMenu.cs
Normal file
32
scripts/components/gui/PauseMenu.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PauseMenu : Control
|
||||
{
|
||||
private static PauseMenu Instance;
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void Continue()
|
||||
{
|
||||
Visible = false;
|
||||
GetTree().Paused = false;
|
||||
}
|
||||
public void Restart()
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
GetTree().ReloadCurrentScene();
|
||||
}
|
||||
public void Exit()
|
||||
{
|
||||
GetNode<AudioStreamPlayer>("Audio").Play();
|
||||
GetNode<AudioStreamPlayer>("Audio").Finished += () => { GetTree().Quit(); };
|
||||
}
|
||||
public static void Pause()
|
||||
{
|
||||
Instance.Visible = true;
|
||||
Instance.GetTree().Paused = true;
|
||||
}
|
||||
}
|
||||
1
scripts/components/gui/PauseMenu.cs.uid
Normal file
1
scripts/components/gui/PauseMenu.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://gvwhpjoame6m
|
||||
Loading…
Add table
Add a link
Reference in a new issue