整理代码
This commit is contained in:
@@ -57,8 +57,16 @@ function BGM.setChange(func)
|
|||||||
BGM.onChange=func
|
BGM.onChange=func
|
||||||
end
|
end
|
||||||
function BGM.setVol(v)
|
function BGM.setVol(v)
|
||||||
assert(type(v)=='number'and v>=0 and v<=1)
|
assert(type(v)=='number'and v>=0 and v<=1,'Wrong volume')
|
||||||
volume=v
|
volume=v
|
||||||
|
if BGM.playing then
|
||||||
|
if volume>0 then
|
||||||
|
BGM.playing:setVolume(volume)
|
||||||
|
BGM.playing:play()
|
||||||
|
elseif BGM.nowPlay then
|
||||||
|
BGM.playing:pause()
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function BGM.init(list)
|
function BGM.init(list)
|
||||||
BGM.init=nil
|
BGM.init=nil
|
||||||
@@ -92,18 +100,6 @@ function BGM.init(list)
|
|||||||
LOG("No BGM: "..name,5)
|
LOG("No BGM: "..name,5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function BGM.setVol(v)
|
|
||||||
assert(type(v)=='number'and v>=0 and v<=1)
|
|
||||||
volume=v
|
|
||||||
if BGM.playing then
|
|
||||||
if volume>0 then
|
|
||||||
BGM.playing:setVolume(volume)
|
|
||||||
BGM.playing:play()
|
|
||||||
elseif BGM.nowPlay then
|
|
||||||
BGM.playing:pause()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function BGM.play(name)
|
function BGM.play(name)
|
||||||
name=name or BGM.default
|
name=name or BGM.default
|
||||||
if not _tryLoad(name)then return end
|
if not _tryLoad(name)then return end
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ function SFX.getCount()
|
|||||||
return #sfxList
|
return #sfxList
|
||||||
end
|
end
|
||||||
function SFX.setVol(v)
|
function SFX.setVol(v)
|
||||||
assert(type(v)=='number'and v>=0 and v<=1)
|
assert(type(v)=='number'and v>=0 and v<=1,'Wrong volume')
|
||||||
volume=v
|
volume=v
|
||||||
end
|
end
|
||||||
function SFX.setStereo(v)
|
function SFX.setStereo(v)
|
||||||
assert(type(v)=='number'and v>=0 and v<=1)
|
assert(type(v)=='number'and v>=0 and v<=1,'Wrong stereo')
|
||||||
stereo=v
|
stereo=v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -115,8 +115,9 @@ function scene.keyDown(key)
|
|||||||
for _=1,12 do scene.keyDown("up")end
|
for _=1,12 do scene.keyDown("up")end
|
||||||
elseif key=="right"or key=="pagedown"then
|
elseif key=="right"or key=="pagedown"then
|
||||||
for _=1,12 do scene.keyDown("down")end
|
for _=1,12 do scene.keyDown("down")end
|
||||||
elseif key=="link"then
|
elseif key=="application"then
|
||||||
love.system.openURL(_getList()[selected].url)
|
local url=_getList()[selected].url
|
||||||
|
if url then love.system.openURL(url)end
|
||||||
elseif key=="delete"then
|
elseif key=="delete"then
|
||||||
if inputBox:hasText()then
|
if inputBox:hasText()then
|
||||||
_clearResult()
|
_clearResult()
|
||||||
@@ -213,7 +214,7 @@ scene.widgetList={
|
|||||||
WIDGET.newText{name='book', x=20,y=15,font=70,align='L',fText=CHAR.icon.zBook},
|
WIDGET.newText{name='book', x=20,y=15,font=70,align='L',fText=CHAR.icon.zBook},
|
||||||
WIDGET.newText{name='title', x=100,y=15,font=70,align='L'},
|
WIDGET.newText{name='title', x=100,y=15,font=70,align='L'},
|
||||||
inputBox,
|
inputBox,
|
||||||
WIDGET.newKey{name='link', x=1120,y=655,w=80,font=55,fText=CHAR.icon.globe, code=pressKey"link",hideF=function()return not _getList()[selected].url end},
|
WIDGET.newKey{name='link', x=1120,y=655,w=80,font=55,fText=CHAR.icon.globe, code=pressKey"application",hideF=function()return not _getList()[selected].url end},
|
||||||
WIDGET.newKey{name='copy', x=1210,y=655,w=80,font=50,fText=CHAR.icon.copy, code=pressKey"cC"},
|
WIDGET.newKey{name='copy', x=1210,y=655,w=80,font=50,fText=CHAR.icon.copy, code=pressKey"cC"},
|
||||||
WIDGET.newKey{name='up', x=1120,y=475,w=80,font=50,fText=CHAR.key.up, code=pressKey"up",hide=not MOBILE},
|
WIDGET.newKey{name='up', x=1120,y=475,w=80,font=50,fText=CHAR.key.up, code=pressKey"up",hide=not MOBILE},
|
||||||
WIDGET.newKey{name='down', x=1120,y=565,w=80,font=50,fText=CHAR.key.down, code=pressKey"down",hide=not MOBILE},
|
WIDGET.newKey{name='down', x=1120,y=565,w=80,font=50,fText=CHAR.key.down, code=pressKey"down",hide=not MOBILE},
|
||||||
|
|||||||
Reference in New Issue
Block a user