Optimised code
This commit is contained in:
@@ -33,7 +33,8 @@ public partial class CommonData : Node
|
||||
GetTree().Root.CallDeferred(Node.MethodName.AddChild, inst);
|
||||
|
||||
// Start game by loading the main menu
|
||||
scene = GD.Load<PackedScene>("res://Assets/Scenes/MenusAndLevels/MainMenu.tscn");
|
||||
//scene = GD.Load<PackedScene>("res://Assets/Scenes/MenusAndLevels/MainMenu.tscn");
|
||||
scene = GD.Load<PackedScene>("res://Assets/Scenes/DEVSCENES/EnemyTest.tscn");
|
||||
inst = scene.Instantiate();
|
||||
GetTree().Root.CallDeferred(Node.MethodName.AddChild, inst);
|
||||
PlayMusic("MainMenu");
|
||||
@@ -47,11 +48,9 @@ public partial class CommonData : Node
|
||||
NumFramesElapsed += 1;
|
||||
GlobalTimer = NumFramesElapsed / FPS;
|
||||
GlobalTimer = (float)Convert.ToDouble(GlobalTimer.ToString("0.##")); // Truncates seconds elapsed to hundreds place (0.00)
|
||||
//GD.Print(GlobalTimer);
|
||||
if (Input.IsActionJustPressed("quit_game")){GetTree().Quit();}
|
||||
|
||||
if (Input.IsActionJustPressed("quit_game"))
|
||||
{
|
||||
GetTree().Quit();
|
||||
}
|
||||
if (Input.IsActionJustPressed("mute"))
|
||||
{
|
||||
if (Muted)
|
||||
@@ -68,20 +67,13 @@ public partial class CommonData : Node
|
||||
}
|
||||
|
||||
// BG Audio Management
|
||||
public void StopMusic()
|
||||
{
|
||||
// Stop whatever audio is playing
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stop();
|
||||
}
|
||||
public void StopMusic(){GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stop();}// Stop whatever audio is playing\
|
||||
|
||||
public void PlayMusic(string AudioName)
|
||||
{
|
||||
// Load target audio and play the audio
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stream = (Godot.AudioStream)GD.Load($"res://Assets/Audio/Music/{AudioName}.mp3");
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Play();
|
||||
}
|
||||
void LoopAudio()
|
||||
{
|
||||
// Find when the stream finishes playing to play it again
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Play();
|
||||
}
|
||||
void LoopAudio(){GetNode<AudioStreamPlayer>("AudioStreamPlayer").Play();}// Find when the stream finishes playing to play it again
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user