再调整SFX.playSample方法,支持用数字代表绝对音高,但是移除最后的音量参数

This commit is contained in:
MrZ626
2021-11-15 01:40:53 +08:00
parent ae61ec26c0
commit 503dfd69ef

View File

@@ -79,18 +79,18 @@ function SFX.setStereo(v)
stereo=v stereo=v
end end
function SFX.playSample(pack,...)--vol-2, sampSet1, vol-3, sampSet2, vol-1 function SFX.playSample(pack,...)--vol-1, sampSet1, vol-2, sampSet2
if ... then if ... then
local arg={...} local arg={...}
local vol local vol
if type(arg[#arg])=='number'then vol=rem(arg)end
for i=1,#arg do for i=1,#arg do
if type(arg[i])=='number'then local a=arg[i]
vol=arg[i] if type(a)=='number'and a<=1 then
vol=a
else else
local base=packSetting[pack].base local base=packSetting[pack].base
local top=packSetting[pack].top local top=packSetting[pack].top
local tune=_getTuneHeight(arg[i])--Absolute tune in number local tune=type(a)=='string'and _getTuneHeight(a)or a--Absolute tune in number
local playTune=tune+rnd(-2,2) local playTune=tune+rnd(-2,2)
if playTune<=base then--Too low notes if playTune<=base then--Too low notes
playTune=base+1 playTune=base+1