From 601591c7dbfb18d3b289b825450909e0b23ecb6f Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Thu, 18 Mar 2021 12:43:32 +0800 Subject: [PATCH] =?UTF-8?q?BGM=E5=92=8CBG=E6=A8=A1=E5=9D=97=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E6=88=90=E5=8A=9F=EF=BC=88=E5=8C=85=E6=8B=AC=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=EF=BC=89=E8=BF=94=E5=9B=9Etrue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/background.lua | 25 ++++++++++++++----------- Zframework/bgm.lua | 21 ++++++++++++--------- 2 files changed, 26 insertions(+), 20 deletions(-) diff --git a/Zframework/background.lua b/Zframework/background.lua index a6ed2832..612f3824 100644 --- a/Zframework/background.lua +++ b/Zframework/background.lua @@ -34,17 +34,20 @@ function BG.setDefault(bg) end function BG.set(background) if not background then background=BG.default end - if not BGs[background]or background==BG.cur or not SETTING.bg then return end - BG.discard() - BG.cur=background - background=BGs[background] + if not BGs[background]or not SETTING.bg then return end + if background~=BG.cur then + BG.discard() + BG.cur=background + background=BGs[background] - BG.init= background.init or NULL - BG.resize= background.resize or NULL - BG.update= background.update or NULL - BG.draw= background.draw or NULL - BG.event= background.event or NULL - BG.discard= background.discard or NULL - BG.init() + BG.init= background.init or NULL + BG.resize= background.resize or NULL + BG.update= background.update or NULL + BG.draw= background.draw or NULL + BG.event= background.event or NULL + BG.discard= background.discard or NULL + BG.init() + end + return true end return BG \ No newline at end of file diff --git a/Zframework/bgm.lua b/Zframework/bgm.lua index bce0105b..acfb0d2a 100644 --- a/Zframework/bgm.lua +++ b/Zframework/bgm.lua @@ -63,17 +63,20 @@ function BGM.init(list) if SETTING.bgm==0 then BGM.nowPlay=s BGM.playing=Sources[s] - return + return true end - if s and Sources[s]and BGM.nowPlay~=s then - if BGM.nowPlay then TASK.new(fadeOut,BGM.playing)end - TASK.removeTask_iterate(removeCurFadeOut,fadeOut,Sources[s]) - TASK.removeTask_code(fadeIn) + if s and Sources[s]then + if BGM.nowPlay~=s then + if BGM.nowPlay then TASK.new(fadeOut,BGM.playing)end + TASK.removeTask_iterate(removeCurFadeOut,fadeOut,Sources[s]) + TASK.removeTask_code(fadeIn) - TASK.new(fadeIn,Sources[s]) - BGM.nowPlay=s - BGM.playing=Sources[s] - BGM.playing:play() + TASK.new(fadeIn,Sources[s]) + BGM.nowPlay=s + BGM.playing=Sources[s] + BGM.playing:play() + end + return true end end function BGM.freshVolume()