多媒体库再完善,未初始化时调用不会报错了

This commit is contained in:
MrZ626
2020-12-10 13:18:43 +08:00
parent 5c073257b7
commit 8e1c53b1e7
5 changed files with 27 additions and 8 deletions

View File

@@ -1,4 +1,9 @@
local BGM={
getList={},
getCount=function()return 0 end,
play=NULL,
freshVolume=NULL,
stop=NULL,
--nowPlay=[str:playing ID]
--playing=[src:playing SRC]
}

View File

@@ -8,11 +8,13 @@ function IMG.init(list)
end
function IMG.getCount()return count end
IMG.loadOne=coroutine.wrap(function()
IMG.loadOne=coroutine.wrap(function(skip)
IMG.loadAll=nil
for k,v in next,list do
IMG[k]=love.graphics.newImage("media/image/"..v)
coroutine.yield()
if not skip and i~=count then
coroutine.yield()
end
end
IMG.loadOne=nil
end)

View File

@@ -531,7 +531,7 @@ function love.run()
gc.print("Memory:"..gcinfo(),SCR.safeX+5,_-40)
gc.print("Lines:"..FREEROW.getCount(),SCR.safeX+5,_-60)
gc.print("Cursor:"..int(mx+.5).." "..int(my+.5),SCR.safeX+5,_-80)
gc.print("Voices:"..VOC.getCount(),SCR.safeX+5,_-100)
gc.print("Voices:"..VOC.getQueueCount(),SCR.safeX+5,_-100)
gc.print("Tasks:"..TASK.getCount(),SCR.safeX+5,_-120)
ins(frameTimeList,1,dt)rem(frameTimeList,126)
gc.setColor(1,1,1,.3)

View File

@@ -1,4 +1,10 @@
local SFX={}
local SFX={
getCount=function()return 0 end,
fieldPlay=NULL,
play=NULL,
fplay=NULL,
reset=NULL,
}
function SFX.init(list)
SFX.init=nil
local rem=table.remove

View File

@@ -1,4 +1,10 @@
local VOC={}
local VOC={
getCount=function()return 0 end,
getQueueCount=NULL,
getFreeChannel=NULL,
play=NULL,
update=NULL,
}
function VOC.init(list)
VOC.init=nil
@@ -52,6 +58,9 @@ function VOC.init(list)
end
VOC.loadOne=nil
function VOC.getQueueCount()
return #voiceQueue
end
function VOC.getFreeChannel()
local l=#voiceQueue
for i=1,l do
@@ -60,9 +69,6 @@ function VOC.init(list)
voiceQueue[l+1]={s=0}
return l+1
end
function VOC.getCount()
return #voiceQueue
end
function VOC.play(s,chn)
if SETTING.voc>0 then