整理背景加载代码和程序初始化流程
This commit is contained in:
@@ -1,22 +1,33 @@
|
||||
local BGlist={}
|
||||
local BG={
|
||||
list={},
|
||||
cur="",
|
||||
init=NULL,
|
||||
resize=NULL,
|
||||
init=nil,
|
||||
resize=nil,
|
||||
update=NULL,
|
||||
draw=NULL,
|
||||
event=NULL,
|
||||
event=nil,
|
||||
discard=NULL,
|
||||
}
|
||||
function BG.send(data)
|
||||
|
||||
--Load Background files from SOURCE ONLY
|
||||
for _,v in next,love.filesystem.getDirectoryItems("parts/backgrounds")do
|
||||
if love.filesystem.getRealDirectory("parts/backgrounds/"..v)~=SAVEDIR then
|
||||
local name=v:sub(1,-5)
|
||||
BGlist[name]=require("parts/backgrounds/"..name)
|
||||
else
|
||||
LOG.print("Dangerous file : %SAVE%/parts/backgrounds/"..v)
|
||||
end
|
||||
end
|
||||
|
||||
function BG.send(...)
|
||||
if BG.event then
|
||||
BG.event(data)
|
||||
BG.event(...)
|
||||
end
|
||||
end
|
||||
function BG.set(background)
|
||||
if background==BG.cur or not SETTING.bg then return end
|
||||
BG.discard()
|
||||
background=BG.list[background]
|
||||
background=BGlist[background]
|
||||
if not background then
|
||||
LOG.print("No BG called"..background,"warn")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user