From 1ea920761a40e0ec549a98c8a9a27e1c7429beb2 Mon Sep 17 00:00:00 2001 From: MrZ_26 <1046101471@qq.com> Date: Thu, 2 May 2024 02:38:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AEfmod=E6=A8=A1=E5=9D=97=E9=9F=B3?= =?UTF-8?q?=E4=B9=90=E6=B7=A1=E5=87=BA=E6=95=88=E6=9E=9C=E6=9C=AA=E7=94=9F?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/fmod20221/init.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/assets/fmod20221/init.lua b/assets/fmod20221/init.lua index 34b11854..e7aaa5a0 100644 --- a/assets/fmod20221/init.lua +++ b/assets/fmod20221/init.lua @@ -170,6 +170,7 @@ function M.music.play(name,args) return event end +---Set current playing music fading out (need param 'fade' in event) ---@param instant? boolean only `true` take effect function M.music.stop(instant) if not playing then return end @@ -178,10 +179,11 @@ function M.music.stop(instant) e:stop(M.FMOD_STUDIO_STOP_IMMEDIATE) else TASK.new(function() - e:setParameterByName('fade',0,true) + e:setParameterByName('fade',0,false) repeat - coroutine.yield() - until e:getParameterByName('fade')==0 + DEBUG.yieldT(0.26) + local _,v=e:getParameterByName('fade') + until v<=0 e:stop(M.FMOD_STUDIO_STOP_IMMEDIATE) end) end