Skip to content

Commit

Permalink
修fmod模块音乐淡出效果未生效
Browse files Browse the repository at this point in the history
  • Loading branch information
MrZ626 committed May 1, 2024
1 parent 611a63c commit 1ea9207
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions assets/fmod20221/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 1ea9207

Please sign in to comment.