improvement: only change current music when new
It'll avoid having the music resetting every time you enter a new map with the same music (entering in a house for instance)
This commit is contained in:
parent
fcafa9aa0f
commit
be54412284
1 changed files with 8 additions and 2 deletions
|
@ -63,6 +63,8 @@ function OverWorld:new(area, playerx, playery)
|
|||
self.message = "Test de message"
|
||||
self.messageOpacity = 0
|
||||
|
||||
self.isPlaying = ""
|
||||
|
||||
self.events = EventManager(self)
|
||||
end
|
||||
|
||||
|
@ -73,8 +75,12 @@ function OverWorld:updateCurrentMap(map)
|
|||
end
|
||||
|
||||
function OverWorld:playMapMusic(map)
|
||||
self.assets:setMusic("assets/music/" .. map.music .. ".mp3")
|
||||
self.assets:playMusic()
|
||||
local newMusic = map.music
|
||||
if (newMusic ~= self.isPlaying) then
|
||||
self.assets:setMusic("assets/music/" .. newMusic .. ".mp3")
|
||||
self.assets:playMusic()
|
||||
self.isPlaying = newMusic
|
||||
end
|
||||
end
|
||||
|
||||
function OverWorld:startEvent()
|
||||
|
|
Loading…
Reference in a new issue