From 62b3ae5789fe09834b8d4ece12425bd7f08c6d83 Mon Sep 17 00:00:00 2001 From: Top Cat Date: Mon, 16 Dec 2013 20:43:55 +0000 Subject: [PATCH] Fix music being started multiple times --- main.lua | 7 ++++++- manager/game.lua | 4 ++-- manager/levelcomplete.lua | 4 ++-- manager/victory.lua | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/main.lua b/main.lua index f68f025..4a19af8 100755 --- a/main.lua +++ b/main.lua @@ -8,7 +8,12 @@ function love.load() music = love.audio.newSource("sound/golden-streets.mp3") music:setLooping(true) love.audio.play(music) - setManager(Menu:new(setManager, love.load)) + + restart() +end + +function restart() + setManager(Menu:new(setManager, restart)) end function love.update(dt) diff --git a/manager/game.lua b/manager/game.lua index 373ddb5..184e257 100755 --- a/manager/game.lua +++ b/manager/game.lua @@ -145,13 +145,13 @@ function Game:update(dt) if self.state[self.playerId] and self.state[self.playerId].health <= 0 then -- Player is dead. - self.setManager(GameOver:new(setManager, love.load)) + self.setManager(GameOver:new(setManager, restart)) return end if self.state[self.playerId] ~= nil and self.state[self.playerId].y > 800 then --Falling Death - self.setManager(GameOver:new(setManager, love.load)) + self.setManager(GameOver:new(setManager, restart)) return end diff --git a/manager/levelcomplete.lua b/manager/levelcomplete.lua index c9cdad6..da565f5 100644 --- a/manager/levelcomplete.lua +++ b/manager/levelcomplete.lua @@ -17,14 +17,14 @@ end function LevelComplete:load() self.backgroundImage = love.graphics.newImage("assets/levelcomplete.png") if self.nextLevel == 4 then - self.setManager(Victory:new(setManager, love.load)) + self.setManager(Victory:new(setManager, restart)) end end function LevelComplete:keypressed(key, unicode) if key == "return" then self.setManager(Game:new(self.class.levels[self.nextLevel], self.nextLevel, - setManager, love.load)) + setManager, restart)) end end diff --git a/manager/victory.lua b/manager/victory.lua index d3c0bc7..9737110 100755 --- a/manager/victory.lua +++ b/manager/victory.lua @@ -9,7 +9,7 @@ end function Victory:keypressed(key, unicode) if key == "return" then - self.setManager(Menu:new(setManager, love.load)) + self.setManager(Menu:new(setManager, restart)) end end