diff --git a/DungeonShooting_Godot/src/game/manager/SoundManager.cs b/DungeonShooting_Godot/src/game/manager/SoundManager.cs index d7dfd26..82a64e1 100644 --- a/DungeonShooting_Godot/src/game/manager/SoundManager.cs +++ b/DungeonShooting_Godot/src/game/manager/SoundManager.cs @@ -47,6 +47,9 @@ public void OnPlayFinish() { + GetParent().RemoveChild(this); + Stream = null; + Playing = false; RecycleAudioPlayer(this); } } @@ -161,13 +164,6 @@ /// private static void RecycleAudioPlayer(AudioPlayer inst) { - var parent = inst.GetParent(); - if (parent != null) - { - parent.RemoveChild(inst); - } - - inst.Stream = null; _streamPlayerStack.Push(inst); } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/manager/SpecialEffectManager.cs b/DungeonShooting_Godot/src/game/manager/SpecialEffectManager.cs index 0f58ee7..5660971 100644 --- a/DungeonShooting_Godot/src/game/manager/SpecialEffectManager.cs +++ b/DungeonShooting_Godot/src/game/manager/SpecialEffectManager.cs @@ -8,8 +8,6 @@ public static class SpecialEffectManager { - private static Stack _specialEffectStack = new Stack(); - /// /// 基础特效播放类, 用于播放序列帧动画特效, 播完就回收 /// @@ -37,7 +35,7 @@ private void Over() { currLoopCount = 0; - RecycleSpecialEffect(this); + QueueFree(); } } @@ -56,8 +54,7 @@ public static void Play(string path, string animName, Vector2 pos, float rotation, Vector2 scale, Vector2 offset, int zIndex = 0, float speed = 1, int loopCount = 1) { var spriteFrames = ResourceManager.Load(path); - - var specialEffect = GetSpecialEffect(); + var specialEffect = new SpecialEffect(); specialEffect.GlobalPosition = pos; specialEffect.Rotation = rotation; specialEffect.Scale = scale; @@ -69,30 +66,4 @@ specialEffect.Play(animName); GameApplication.Instance.Room.GetRoot(true).AddChild(specialEffect); } - - private static SpecialEffect GetSpecialEffect() - { - if (_specialEffectStack.Count > 0) - { - return _specialEffectStack.Pop(); - } - - return new SpecialEffect(); - } - - /// - /// 回收2D音频播放节点 - /// - private static void RecycleSpecialEffect(SpecialEffect inst) - { - var parent = inst.GetParent(); - if (parent != null) - { - parent.RemoveChild(inst); - } - - inst.Playing = false; - inst.Frames = null; - _specialEffectStack.Push(inst); - } } \ No newline at end of file