均匀音量调节
This commit is contained in:
@@ -3,7 +3,7 @@ local rem=table.remove
|
|||||||
|
|
||||||
local function fadeOut(id)
|
local function fadeOut(id)
|
||||||
local src=BGM.list[id]
|
local src=BGM.list[id]
|
||||||
local v=src:getVolume()-.025*setting.bgm*.1
|
local v=src:getVolume()-.025*setting.bgm*.01
|
||||||
src:setVolume(v>0 and v or 0)
|
src:setVolume(v>0 and v or 0)
|
||||||
if v<=0 then
|
if v<=0 then
|
||||||
src:stop()
|
src:stop()
|
||||||
@@ -12,9 +12,10 @@ local function fadeOut(id)
|
|||||||
end
|
end
|
||||||
local function fadeIn(id)
|
local function fadeIn(id)
|
||||||
local src=BGM.list[id]
|
local src=BGM.list[id]
|
||||||
local v=min(src:getVolume()+.025*setting.bgm*.1,setting.bgm*.1)
|
local v=setting.bgm*.01
|
||||||
|
v=min(v,src:getVolume()+.025*v)
|
||||||
src:setVolume(v)
|
src:setVolume(v)
|
||||||
if v>=setting.bgm*.1 then return true end
|
if v>=setting.bgm*.01 then return true end
|
||||||
end
|
end
|
||||||
|
|
||||||
local BGM={
|
local BGM={
|
||||||
@@ -67,7 +68,7 @@ function BGM.play(s)
|
|||||||
end
|
end
|
||||||
function BGM.freshVolume()
|
function BGM.freshVolume()
|
||||||
if BGM.playing then
|
if BGM.playing then
|
||||||
local v=setting.bgm*.1
|
local v=setting.bgm*.01
|
||||||
if v>0 then
|
if v>0 then
|
||||||
BGM.playing:setVolume(v)
|
BGM.playing:setVolume(v)
|
||||||
if BGM.suspend then
|
if BGM.suspend then
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ function SFX.loadAll()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
function SFX.fieldPlay(s,v,P)
|
function SFX.fieldPlay(s,v,P)
|
||||||
SFX.play(s,v,(P.curX+P.sc[2]-6.5)*.15)
|
SFX.play(s,v,(P.curX+P.sc[2]-5.5)*.15)
|
||||||
end
|
end
|
||||||
function SFX.play(s,vol,pos,force)
|
function SFX.play(s,vol,pos)
|
||||||
if setting.sfx==0 and not force then return end
|
if setting.sfx==0 then return end
|
||||||
local S=SFX.list[s]--Source list
|
local S=SFX.list[s]--Source list
|
||||||
if not S then return end
|
if not S then return end
|
||||||
local n=1
|
local n=1
|
||||||
@@ -58,11 +58,31 @@ function SFX.play(s,vol,pos,force)
|
|||||||
S:setPosition(0,0,0)
|
S:setPosition(0,0,0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not force then
|
S:setVolume(((vol or 1)*setting.sfx*.01)^1.626)
|
||||||
S:setVolume((vol or 1)*setting.sfx*.1)
|
S:play()
|
||||||
else
|
end
|
||||||
S:setVolume(vol*.1)
|
function SFX.fplay(s,vol,pos)
|
||||||
|
local S=SFX.list[s]--Source list
|
||||||
|
if not S then return end
|
||||||
|
local n=1
|
||||||
|
while S[n]:isPlaying()do
|
||||||
|
n=n+1
|
||||||
|
if not S[n]then
|
||||||
|
S[n]=S[1]:clone()
|
||||||
|
S[n]:seek(0)
|
||||||
|
break
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
S=S[n]--AU_SRC
|
||||||
|
if S:getChannelCount()==1 then
|
||||||
|
if pos then
|
||||||
|
pos=pos*setting.stereo*.1
|
||||||
|
S:setPosition(pos,1-pos^2,0)
|
||||||
|
else
|
||||||
|
S:setPosition(0,0,0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
S:setVolume((vol*.01)^1.626)
|
||||||
S:play()
|
S:play()
|
||||||
end
|
end
|
||||||
function SFX.reset()
|
function SFX.reset()
|
||||||
|
|||||||
@@ -207,22 +207,25 @@ end
|
|||||||
function slider:draw()
|
function slider:draw()
|
||||||
local x,y=self.x,self.y
|
local x,y=self.x,self.y
|
||||||
local ATV=self.ATV
|
local ATV=self.ATV
|
||||||
|
local x2=x+self.w
|
||||||
|
|
||||||
|
gc.setColor(1,1,1,.5+ATV*.06)
|
||||||
|
|
||||||
--Units
|
--Units
|
||||||
gc.setColor(1,1,1,.5+ATV*.06)
|
if self.showUnit then
|
||||||
gc.setLineWidth(2)
|
gc.setLineWidth(2)
|
||||||
local x1,x2=x,x+self.w
|
|
||||||
for p=0,self.unit do
|
for p=0,self.unit do
|
||||||
local x=x1+(x2-x1)*p/self.unit
|
local x=x+(x2-x)*p/self.unit
|
||||||
gc.line(x,y+7,x,y-7)
|
gc.line(x,y+7,x,y-7)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
--Axis
|
--Axis
|
||||||
gc.setLineWidth(4)
|
gc.setLineWidth(4)
|
||||||
gc.line(x1,y,x2,y)
|
gc.line(x,y,x2,y)
|
||||||
|
|
||||||
--Block
|
--Block
|
||||||
local bx,by,bw,bh=x1+(x2-x1)*self.pos/self.unit-10-ATV*.5,y-16-ATV,20+ATV,32+2*ATV
|
local bx,by,bw,bh=x+(x2-x)*self.pos/self.unit-10-ATV*.5,y-16-ATV,20+ATV,32+2*ATV
|
||||||
gc.setColor(.8,.8,.8)
|
gc.setColor(.8,.8,.8)
|
||||||
gc.rectangle("fill",bx,by,bw,bh)
|
gc.rectangle("fill",bx,by,bw,bh)
|
||||||
if ATV>0 then
|
if ATV>0 then
|
||||||
@@ -367,6 +370,7 @@ function WIDGET.newSlider(D)
|
|||||||
},
|
},
|
||||||
|
|
||||||
unit= D.unit,
|
unit= D.unit,
|
||||||
|
showUnit=not D.noUnit,
|
||||||
font= D.font,
|
font= D.font,
|
||||||
change= D.change,
|
change= D.change,
|
||||||
disp= D.disp,
|
disp= D.disp,
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ local Widgets={
|
|||||||
newButton({name="back", x=1200,y=655,w=120,h=80,color="white", font=40,code=BACK}),
|
newButton({name="back", x=1200,y=655,w=120,h=80,color="white", font=40,code=BACK}),
|
||||||
},
|
},
|
||||||
music={
|
music={
|
||||||
newSlider({name="bgm", x=760, y=80, w=400, unit=10, font=35,change=function()BGM.freshVolume()end,disp=SETval("bgm"),code=SETsto("bgm")}),
|
newSlider({name="bgm", x=760, y=80, w=400,unit=100, noUnit=true, font=35,change=function()BGM.freshVolume()end,disp=SETval("bgm"),code=SETsto("bgm")}),
|
||||||
newButton({name="up", x=1100, y=200, w=120,h=120, color="white", font=55,code=pressKey("up")}),
|
newButton({name="up", x=1100, y=200, w=120,h=120, color="white", font=55,code=pressKey("up")}),
|
||||||
newButton({name="play", x=1100, y=340, w=120,h=120, color="white", font=35,code=pressKey("space"),hide=function()return setting.bgm==0 end}),
|
newButton({name="play", x=1100, y=340, w=120,h=120, color="white", font=35,code=pressKey("space"),hide=function()return setting.bgm==0 end}),
|
||||||
newButton({name="down", x=1100, y=480, w=120,h=120, color="white", font=55,code=pressKey("down")}),
|
newButton({name="down", x=1100, y=480, w=120,h=120, color="white", font=55,code=pressKey("down")}),
|
||||||
@@ -276,10 +276,10 @@ local Widgets={
|
|||||||
setting_sound={
|
setting_sound={
|
||||||
newButton({name="game", x=200, y=80,w=240,h=80,color="lCyan",font=35,code=function()SCN.swapTo("setting_game","swipe")end}),
|
newButton({name="game", x=200, y=80,w=240,h=80,color="lCyan",font=35,code=function()SCN.swapTo("setting_game","swipe")end}),
|
||||||
newButton({name="graphic", x=1080, y=80,w=240,h=80,color="lCyan",font=35,code=function()SCN.swapTo("setting_video","swipe")end}),
|
newButton({name="graphic", x=1080, y=80,w=240,h=80,color="lCyan",font=35,code=function()SCN.swapTo("setting_video","swipe")end}),
|
||||||
newSlider({name="sfx", x=180, y=200,w=400,unit=10,font=35,change=function()SFX.play("blip_1")end, disp=SETval("sfx"), code=SETsto("sfx")}),
|
newSlider({name="sfx", x=180, y=200,w=400,unit=100,noUnit=true,font=35,change=function()SFX.play("blip_1")end, disp=SETval("sfx"), code=SETsto("sfx")}),
|
||||||
newSlider({name="stereo", x=180, y=500,w=400,unit=10,font=35,change=function()SFX.play("move",1,-1)SFX.play("lock",1,1)end, disp=SETval("stereo"), code=SETsto("stereo"),hide=function()return setting.sfx==0 end}),
|
newSlider({name="stereo", x=180, y=500,w=400,unit=10,font=35,change=function()SFX.play("move",1,-1)SFX.play("lock",1,1)end, disp=SETval("stereo"), code=SETsto("stereo"),hide=function()return setting.sfx==0 end}),
|
||||||
newSlider({name="spawn", x=180, y=300,w=400,unit=10,font=30,change=function()SFX.play("spawn_1",setting.spawn,nil,true)end, disp=SETval("spawn"), code=SETsto("spawn")}),
|
newSlider({name="spawn", x=180, y=300,w=400,unit=10,font=30,change=function()SFX.fplay("spawn_1",setting.spawn)end, disp=SETval("spawn"), code=SETsto("spawn")}),
|
||||||
newSlider({name="bgm", x=180, y=400,w=400,unit=10,font=35,change=function()BGM.freshVolume()end, disp=SETval("bgm"), code=SETsto("bgm")}),
|
newSlider({name="bgm", x=180, y=400,w=400,unit=100,noUnit=true,font=35,change=function()BGM.freshVolume()end, disp=SETval("bgm"), code=SETsto("bgm")}),
|
||||||
newSlider({name="vib", x=750, y=200,w=400,unit=5, font=28,change=function()VIB(2)end, disp=SETval("vib"), code=SETsto("vib")}),
|
newSlider({name="vib", x=750, y=200,w=400,unit=5, font=28,change=function()VIB(2)end, disp=SETval("vib"), code=SETsto("vib")}),
|
||||||
newSlider({name="voc", x=750, y=300,w=400,unit=10,font=32,change=function()VOC.play("nya")end, disp=SETval("voc"), code=SETsto("voc")}),
|
newSlider({name="voc", x=750, y=300,w=400,unit=10,font=32,change=function()VOC.play("nya")end, disp=SETval("voc"), code=SETsto("voc")}),
|
||||||
newButton({name="back", x=1140, y=650,w=200,h=80,color="white",font=40,code=BACK}),
|
newButton({name="back", x=1140, y=650,w=200,h=80,color="white",font=40,code=BACK}),
|
||||||
|
|||||||
Reference in New Issue
Block a user