Skip to content

Commit

Permalink
stopAll for sfx + fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yozzaxia1311 committed Feb 8, 2020
1 parent ba7b51f commit a94cf09
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
13 changes: 13 additions & 0 deletions core/audio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ function mmSfx.stop(s)
loader.get(s):stop()
end

function mmSfx.stopAll()
for k, v in pairs(loader.resources) do
if v.type and v:type() == "Source" then
v:stop()
end
end
for k, v in pairs(loader.locked) do
if v.type and v:type() == "Source" then
v:stop()
end
end
end

mmMusic = class:extend()

mmMusic.cur = nil
Expand Down
12 changes: 8 additions & 4 deletions core/megautils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,18 @@ function megautils.runFile(path)
return love.filesystem.load(path)()
end

function megautils.resetGame()
love.audio.stop()
mmMusic.stopMusic()
function megautils.resetGame(s, saveSfx, saveMusic)
if not saveSfx then
mmSfx.stopAll()
end
if not saveMusic then
mmMusic.stopMusic()
end
globals.resetState = true
globals.manageStageResources = true
megautils.unload()
initEngine()
states.set("states/disclaimer.state.lua")
states.set(s or "states/disclaimer.state.lua")
end

function megautils.load()
Expand Down
2 changes: 1 addition & 1 deletion states/title.state.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function title:update(dt)
megautils.add(fade, true, nil, nil, function(s)
mmMusic.lock = true
control.returning = function()
megautils.add(fade, true, nil, nil, function(s) megautils.resetGame() states.set("states/title.state.lua") end)
megautils.add(fade, true, nil, nil, function(s) megautils.resetGame("states/title.state.lua", false, true) end)
end
states.set()
end)
Expand Down

0 comments on commit a94cf09

Please sign in to comment.