整理Zframework代码
给所有模块进行更合理的分类 解除部分模块之间的依赖 修复image和bgm模块两个一般不会触发的小问题 close #209
This commit is contained in:
@@ -24,8 +24,24 @@ function BGM.init(list)
|
||||
function BGM.getList()return simpList end
|
||||
local count=#simpList
|
||||
function BGM.getCount()return count end
|
||||
function BGM.loadAll()for name in next,Sources do load(name)end end
|
||||
|
||||
local function load(name)
|
||||
if type(Sources[name])=='string'then
|
||||
if love.filesystem.getInfo(Sources[name])then
|
||||
Sources[name]=love.audio.newSource(Sources[name],'stream')
|
||||
Sources[name]:setLooping(true)
|
||||
Sources[name]:setVolume(0)
|
||||
return true
|
||||
else
|
||||
MES.new('warn',"No BGM file: "..Sources[name],5)
|
||||
end
|
||||
elseif Sources[name]then
|
||||
return true
|
||||
elseif name then
|
||||
MES.new('warn',"No BGM: "..name,5)
|
||||
end
|
||||
end
|
||||
function BGM.loadAll()for name in next,Sources do load(name)end end
|
||||
local function fadeOut(src)
|
||||
while true do
|
||||
coroutine.yield()
|
||||
@@ -51,22 +67,6 @@ function BGM.init(list)
|
||||
local function removeCurFadeOut(task,code,src)
|
||||
return task.code==code and task.args[1]==src
|
||||
end
|
||||
local function load(name)
|
||||
if type(Sources[name])=='string'then
|
||||
if love.filesystem.getInfo(Sources[name])then
|
||||
Sources[name]=love.audio.newSource(Sources[name],'stream')
|
||||
Sources[name]:setLooping(true)
|
||||
Sources[name]:setVolume(0)
|
||||
return true
|
||||
else
|
||||
MES.new('warn',"No BGM file: "..Sources[name],5)
|
||||
end
|
||||
elseif Sources[name]then
|
||||
return true
|
||||
elseif name then
|
||||
MES.new('warn',"No BGM: "..name,5)
|
||||
end
|
||||
end
|
||||
function BGM.play(name)
|
||||
if not name then name=BGM.default end
|
||||
if not load(name)then return end
|
||||
|
||||
Reference in New Issue
Block a user