From 89fb7a765965554965c922aa9aedf96ff6f17962 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 21 Oct 2021 15:51:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83=E8=B5=84=E6=BA=90=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=EF=BC=8C=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=E5=A4=9A=E4=B8=80=E7=82=B9=E7=82=B9log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/bgm.lua | 22 ++++++++++++---------- Zframework/sfx.lua | 5 ++++- parts/scenes/load.lua | 7 +++---- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Zframework/bgm.lua b/Zframework/bgm.lua index d0acecac..c148aaa9 100644 --- a/Zframework/bgm.lua +++ b/Zframework/bgm.lua @@ -1,5 +1,7 @@ +local Sources={} +local volume=1 + local BGM={ - vol=1, default=false, getList=function()error("Cannot getList before initialize!")end, getCount=function()return 0 end, @@ -13,7 +15,7 @@ local BGM={ local function task_fadeOut(src) while true do coroutine.yield() - local v=src:getVolume()-.025*BGM.vol + local v=src:getVolume()-.025*volume src:setVolume(v>0 and v or 0) if v<=0 then src:pause() @@ -24,10 +26,10 @@ end local function task_fadeIn(src) while true do coroutine.yield() - local v=BGM.vol + local v=volume v=math.min(v,src:getVolume()+.025*v) src:setVolume(v) - if v>=BGM.vol then + if v>=volume then return true end end @@ -43,11 +45,10 @@ function BGM.setChange(func) end function BGM.setVol(v) assert(type(v)=='number'and v>=0 and v<=1) - BGM.vol=v + volume=v end function BGM.init(list) BGM.init=nil - local Sources={} local simpList={} for _,v in next,list do @@ -57,6 +58,7 @@ function BGM.init(list) table.sort(simpList) function BGM.getList()return simpList end local count=#simpList + LOG(count.." BGM files loaded") function BGM.getCount()return count end local function _load(name) @@ -77,10 +79,10 @@ function BGM.init(list) end function BGM.setVol(v) assert(type(v)=='number'and v>=0 and v<=1) - BGM.vol=v + volume=v if BGM.playing then - if BGM.vol>0 then - BGM.playing:setVolume(BGM.vol) + if volume>0 then + BGM.playing:setVolume(volume) BGM.playing:play() elseif BGM.nowPlay then BGM.playing:pause() @@ -95,7 +97,7 @@ function BGM.init(list) function BGM.play(name) name=name or BGM.default if not _load(name)then return end - if BGM.vol==0 then + if volume==0 then BGM.nowPlay=name BGM.playing=Sources[name] return true diff --git a/Zframework/sfx.lua b/Zframework/sfx.lua index f2dd64e6..acbc759e 100644 --- a/Zframework/sfx.lua +++ b/Zframework/sfx.lua @@ -40,14 +40,17 @@ function SFX.init(list) for i=1,#list do ins(sfxList,list[i])end end function SFX.load(path) + local c=0 for i=1,#sfxList do local fullPath=path..sfxList[i]..'.ogg' if love.filesystem.getInfo(fullPath)then Sources[sfxList[i]]={love.audio.newSource(fullPath,'static')} + c=c+1 else LOG("No SFX: "..sfxList[i]..'.ogg',.1) end end + LOG(c.."/"..#sfxList.." SFX files loaded") end function SFX.loadSample(pack) assert(type(pack)=='table',"Usage: SFX.loadsample([table])") @@ -61,7 +64,7 @@ function SFX.loadSample(pack) Sources[pack.name..num]={love.audio.newSource(pack.path..'/'..num..'.ogg','static')} num=num+1 end - LOG("Pack "..pack.name.." loaded, "..(num-1).." files") + LOG((num-1).." "..pack.name.." samples loaded") end function SFX.getCount() diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index cabb37e5..3ef6400e 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -23,10 +23,9 @@ local loadingThread=coroutine.wrap(function() end YIELD() YIELD('loadSFX')SFX.load('media/effect/'..SETTING.sfxPack..'/') - YIELD('loadSample') - SFX.loadSample{name='bass',path='media/sample/bass',base='A2'} - SFX.loadSample{name='lead',path='media/sample/lead',base='A3'} - SFX.loadSample{name='bell',path='media/sample/bell',base='A4'} + YIELD('loadSample')SFX.loadSample{name='bass',path='media/sample/bass',base='A2'} + YIELD('loadSample')SFX.loadSample{name='lead',path='media/sample/lead',base='A3'} + YIELD('loadSample')SFX.loadSample{name='bell',path='media/sample/bell',base='A4'} YIELD('loadVoice')VOC.load('media/vocal/'..SETTING.vocPack..'/') YIELD('loadFont')for i=1,17 do getFont(15+5*i)end