Mercurial > vanillian
changeset 33:0d75bfc00f01
Don't restart music every map
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Sun, 16 Dec 2012 13:12:48 +0100 |
| parents | 2f93b3eb6e1c |
| children | f538b3bb3a5b |
| files | main.lua |
| diffstat | 1 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/main.lua Sun Dec 16 12:56:05 2012 +0100 +++ b/main.lua Sun Dec 16 13:12:48 2012 +0100 @@ -14,6 +14,7 @@ local scroll_speed = 250 local scroll_margin = 64 local MUSIC +local LAST_MUSIC local TEXT = "" local SOUNDS = {} @@ -106,12 +107,15 @@ MAP.drawObjects = false MAP.layers['control'].visible = false if MAP.properties.music then - if MUSIC then - MUSIC:stop() + if not LAST_MUSIC or MAP.properties.music ~= LAST_MUSIC then + if MUSIC then + MUSIC:stop() + end + MUSIC = love.audio.newSource(MAP.properties.music, 'static') + MUSIC:setLooping(true) + MUSIC:play() + LAST_MUSIC = MAP.properties.music end - MUSIC = love.audio.newSource(MAP.properties.music, 'static') - MUSIC:setLooping(true) - MUSIC:play() end for i, data in pairs(MAP.layers['mobs'].objects) do if data.name == 'villain' then
