mirror of
https://github.com/SashLilac/cambridge.git
synced 2024-11-21 15:09:02 -06:00
BGM playing changes and bugfixes
This commit is contained in:
parent
a972c31d9a
commit
7199aa7ef6
21
load/bgm.lua
21
load/bgm.lua
@ -7,13 +7,15 @@ bgm = {
|
||||
|
||||
local current_bgm = nil
|
||||
local bgm_locked = false
|
||||
local unfocused = false
|
||||
|
||||
function switchBGM(sound, subsound)
|
||||
if bgm_locked then
|
||||
return
|
||||
end
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:stop()
|
||||
end
|
||||
if bgm_locked or config.bgm_volume <= 0 then
|
||||
if config.bgm_volume <= 0 then
|
||||
current_bgm = nil
|
||||
elseif sound ~= nil then
|
||||
if subsound ~= nil then
|
||||
@ -67,24 +69,19 @@ function processBGMFadeout(dt)
|
||||
fadeout_time = 0
|
||||
fading_bgm = false
|
||||
end
|
||||
current_bgm:setVolume(fadeout_time * config.bgm_volume / total_fadeout_time)
|
||||
current_bgm:setVolume(
|
||||
fadeout_time * config.bgm_volume / total_fadeout_time
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
function pauseBGM(f)
|
||||
if f then
|
||||
unfocused = true
|
||||
end
|
||||
function pauseBGM()
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:pause()
|
||||
end
|
||||
end
|
||||
|
||||
function resumeBGM(f)
|
||||
if f and scene.paused and unfocused then
|
||||
unfocused = false
|
||||
return
|
||||
end
|
||||
function resumeBGM()
|
||||
if current_bgm ~= nil then
|
||||
current_bgm:play()
|
||||
end
|
||||
|
8
main.lua
8
main.lua
@ -280,14 +280,6 @@ function love.wheelmoved(x, y)
|
||||
scene:onInputPress({input=nil, type="wheel", x=x, y=y})
|
||||
end
|
||||
|
||||
function love.focus(f)
|
||||
if f then
|
||||
resumeBGM(true)
|
||||
else
|
||||
pauseBGM(true)
|
||||
end
|
||||
end
|
||||
|
||||
function love.resize(w, h)
|
||||
GLOBAL_CANVAS:release()
|
||||
GLOBAL_CANVAS = love.graphics.newCanvas(w, h)
|
||||
|
@ -16,9 +16,7 @@ function CreditsScene:new()
|
||||
end
|
||||
|
||||
function CreditsScene:update()
|
||||
if love.window.hasFocus() then
|
||||
self.frames = self.frames + 1
|
||||
end
|
||||
self.frames = self.frames + 1
|
||||
if self.frames >= 2100 * self.scroll_speed then
|
||||
playSE("mode_decide")
|
||||
scene = TitleScene()
|
||||
|
Loading…
Reference in New Issue
Block a user