From 8b020844289bf59f4cd1fd8f87aace221f05e20d Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Sun, 21 Nov 2021 05:11:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbgm=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=B8=85=E7=BC=93=E5=AD=98=E5=AF=BC=E8=87=B4=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/bgm.lua | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Zframework/bgm.lua b/Zframework/bgm.lua index 0a1b0dc5..a3864894 100644 --- a/Zframework/bgm.lua +++ b/Zframework/bgm.lua @@ -40,10 +40,17 @@ local function check_curFadeOut(task,code,src) return task.code==code and task.args[1]==src end local function _tryReleaseSources() + local n=#lastLoaded while #lastLoaded>maxLoadedCount do - local n=lastLoaded[#lastLoaded] - SourceObjList[n].source=SourceObjList[n].source:release()and nil - table.remove(lastLoaded) + local name=lastLoaded[n] + if SourceObjList[name].source:isPlaying()then + n=n-1 + if n<=0 then return end + else + SourceObjList[name].source=SourceObjList[name].source:release()and nil + table.remove(lastLoaded,n) + return + end end end function BGM.setDefault(bgm)