自定义游戏的背景列表改为自动读取

This commit is contained in:
MrZ626
2021-01-04 21:54:06 +08:00
parent b565eb7b37
commit 51cc1a44d9
2 changed files with 10 additions and 10 deletions

View File

@@ -1,23 +1,28 @@
local BGlist={
local BGs={
none={
draw=function()
love.graphics.clear(.15,.15,.15)
end
}
}
local BGlist={"none"}
local BG={
cur="none",
default="none",
init=false,
resize=false,
update=NULL,
draw=BGlist.none.draw,
draw=BGs.none.draw,
event=false,
discard=NULL,
}
function BG.add(name,bg)
BGlist[name]=bg
BGs[name]=bg
BGlist[#BGlist+1]=name
end
function BG.getList()
return BGlist
end
function BG.send(...)
if BG.event then
@@ -34,7 +39,7 @@ function BG.set(background)
if background==BG.cur or not SETTING.bg then return end
BG.discard()
BG.cur=background
background=BGlist[background]
background=BGs[background]
if not background then
LOG.print("No BG called"..background,"warn")
return

View File

@@ -153,12 +153,7 @@ scene.widgetList={
WIDGET.newSelector{name="fall", x=410, y=230,w=220,color="yellow", list={0,1,2,3,4,5,6,7,8,10,15,20,30,60}, disp=WIDGET.lnk_CUSval("fall"),code=WIDGET.lnk_CUSsto("fall")},
--Else
WIDGET.newSelector{name="bg",
x=1070, y=150,w=250,color="yellow",
list={"none","grey","glow","rgb","flink","wing","fan","badapple","welcome","aura","bg1","bg2","rainbow","rainbow2","tunnel","lightning","lightning2","matrix","space","snow"},
disp=WIDGET.lnk_CUSval("bg"),
code=function(i)CUSTOMENV.bg=i BG.set(i)end
},
WIDGET.newSelector{name="bg", x=1070, y=150,w=250,color="yellow",list=BG.getList(),disp=WIDGET.lnk_CUSval("bg"), code=function(i)CUSTOMENV.bg=i BG.set(i)end},
WIDGET.newSelector{name="bgm", x=1070, y=230,w=250,color="yellow", list=BGM.getList(), disp=WIDGET.lnk_CUSval("bgm"), code=function(i)CUSTOMENV.bgm=i BGM.play(i)end},
--Copy/Paste/Start