修复之前task模块重构后bgm淡入淡出的任务函数忘了改写

This commit is contained in:
MrZ626
2020-12-06 14:16:27 +08:00
parent 3a90089405
commit ef1ebd509d

View File

@@ -1,20 +1,28 @@
local min=math.min local min=math.min
local function fadeOut(id) local function fadeOut(id)
local src=BGM.list[id] while true do
local v=src:getVolume()-.025*SETTING.bgm coroutine.yield()
src:setVolume(v>0 and v or 0) local src=BGM.list[id]
if v<=0 then local v=src:getVolume()-.025*SETTING.bgm
src:stop() src:setVolume(v>0 and v or 0)
return true if v<=0 then
src:stop()
return true
end
end end
end end
local function fadeIn(id) local function fadeIn(id)
local src=BGM.list[id] while true do
local v=SETTING.bgm coroutine.yield()
v=min(v,src:getVolume()+.025*v) local src=BGM.list[id]
src:setVolume(v) local v=SETTING.bgm
if v>=SETTING.bgm then return true end v=min(v,src:getVolume()+.025*v)
src:setVolume(v)
if v>=SETTING.bgm then
return true
end
end
end end
local BGM={ local BGM={