整理代码
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
local type,assert=type,assert
|
local type,rem=type,table.remove
|
||||||
local ins,rem=table.insert,table.remove
|
|
||||||
|
|
||||||
local sfxList={}
|
local sfxList={}
|
||||||
local packSetting={}
|
local packSetting={}
|
||||||
@@ -37,7 +36,7 @@ local SFX={}
|
|||||||
|
|
||||||
function SFX.init(list)
|
function SFX.init(list)
|
||||||
assert(type(list)=='table',"Initialize SFX lib with a list of filenames!")
|
assert(type(list)=='table',"Initialize SFX lib with a list of filenames!")
|
||||||
for i=1,#list do ins(sfxList,list[i])end
|
for i=1,#list do table.insert(sfxList,list[i])end
|
||||||
end
|
end
|
||||||
function SFX.load(path)
|
function SFX.load(path)
|
||||||
local c=0
|
local c=0
|
||||||
@@ -57,7 +56,7 @@ function SFX.loadSample(pack)
|
|||||||
assert(pack.name,"No field: name")
|
assert(pack.name,"No field: name")
|
||||||
assert(pack.path,"No field: path")
|
assert(pack.path,"No field: path")
|
||||||
packSetting[pack.name]={
|
packSetting[pack.name]={
|
||||||
base=_getTuneHeight(pack.base)or 37,
|
base=(_getTuneHeight(pack.base)or 37)+1,
|
||||||
}
|
}
|
||||||
local num=1
|
local num=1
|
||||||
while love.filesystem.getInfo(pack.path..'/'..num..'.ogg')do
|
while love.filesystem.getInfo(pack.path..'/'..num..'.ogg')do
|
||||||
@@ -79,7 +78,7 @@ function SFX.setStereo(v)
|
|||||||
stereo=v
|
stereo=v
|
||||||
end
|
end
|
||||||
|
|
||||||
function SFX.playSample(pack,...)
|
function SFX.playSample(pack,...)--vol-2, sampSet1, vol-3, sampSet2, vol-1
|
||||||
if ... then
|
if ... then
|
||||||
local arg={...}
|
local arg={...}
|
||||||
local vol
|
local vol
|
||||||
@@ -89,7 +88,7 @@ function SFX.playSample(pack,...)
|
|||||||
vol=arg[i]
|
vol=arg[i]
|
||||||
else
|
else
|
||||||
local tune=arg[i]
|
local tune=arg[i]
|
||||||
tune=_getTuneHeight(tune)-packSetting[pack].base+1
|
tune=_getTuneHeight(tune)-packSetting[pack].base
|
||||||
SFX.play(pack..tune,vol)
|
SFX.play(pack..tune,vol)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user