Improve pause menu
This commit is contained in:
2 files changed
+47
-36
No files matched your search
+31
-20
@@ -37,19 +37,21 @@ public partial class Player : Node2D {
|
||||
}
|
||||
}
|
||||
|
||||
if (VelocityY < 600f) {
|
||||
VelocityY += Globals.Gravity * (float)delta;
|
||||
if (!Globals.IsPaused) {
|
||||
if (VelocityY < 600f) {
|
||||
VelocityY += Globals.Gravity * (float)delta;
|
||||
}
|
||||
|
||||
Pos.Y += VelocityY * (float)delta;
|
||||
|
||||
if (Pos.Y > 976) {
|
||||
Pos.Y = 976;
|
||||
VelocityY = 0;
|
||||
}
|
||||
|
||||
Position = Pos;
|
||||
}
|
||||
|
||||
Pos.Y += VelocityY * (float)delta;
|
||||
|
||||
if (Pos.Y > 976) {
|
||||
Pos.Y = 976;
|
||||
VelocityY = 0;
|
||||
}
|
||||
|
||||
Position = Pos;
|
||||
|
||||
// Effect handling
|
||||
if (Globals.ActiveEffect != "none" && !Globals.IsPaused) {
|
||||
Globals.EffectTimer -= (float)delta;
|
||||
@@ -74,20 +76,29 @@ public partial class Player : Node2D {
|
||||
Globals.BerrySpeed = Globals.DefaultBerrySpeed * 2f;
|
||||
}
|
||||
|
||||
if (Input.IsActionJustPressed("EscapeKey") && !Globals.IsPaused) {
|
||||
PackedScene PauseMenu = GD.Load<PackedScene>("res://Scenes/PauseMenu.tscn");
|
||||
if (Input.IsActionJustPressed("EscapeKey")) {
|
||||
if (!Globals.IsPaused) {
|
||||
PackedScene PauseMenu = GD.Load<PackedScene>("res://Prefabs/PauseMenu.tscn");
|
||||
|
||||
Control PauseMenuInstance = PauseMenu.Instantiate<Control>();
|
||||
Control PauseMenuInstance = PauseMenu.Instantiate<Control>();
|
||||
|
||||
PauseMenuInstance.Position = new Vector2(x: 0, y: 0);
|
||||
PauseMenuInstance.ZIndex = -1;
|
||||
PauseMenuInstance.Position = new Vector2(x: 0, y: 0);
|
||||
PauseMenuInstance.ZIndex = -1;
|
||||
|
||||
GetNode<CanvasLayer>("/root/Game/CanvasLayer").AddChild(PauseMenuInstance);
|
||||
Globals.IsPaused = true;
|
||||
GetNode<CanvasLayer>("/root/Game/CanvasLayer").AddChild(PauseMenuInstance);
|
||||
Globals.IsPaused = true;
|
||||
|
||||
AudioStreamPlayer MusicPlayer = GetNode<AudioStreamPlayer>("/root/Game/MusicPlayer");
|
||||
AudioStreamPlayer MusicPlayer = GetNode<AudioStreamPlayer>("/root/Game/MusicPlayer");
|
||||
|
||||
MusicPlayer.StreamPaused = !MusicPlayer.StreamPaused;
|
||||
MusicPlayer.StreamPaused = !MusicPlayer.StreamPaused;
|
||||
} else {
|
||||
AudioStreamPlayer MusicPlayer = GetNode<AudioStreamPlayer>("/root/Game/MusicPlayer");
|
||||
|
||||
MusicPlayer.StreamPaused = !MusicPlayer.StreamPaused;
|
||||
|
||||
Globals.IsPaused = false;
|
||||
GetNode<Control>("/root/Game/CanvasLayer/PauseMenu").QueueFree();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user