diff options
author | Aki <nthirtyone@gmail.com> | 2017-07-10 21:16:35 +0200 |
---|---|---|
committer | Aki <nthirtyone@gmail.com> | 2017-07-10 21:16:35 +0200 |
commit | 0b3de32ee8b9d79d7b818a6742ab577ff47525e6 (patch) | |
tree | 1e794f9ee41d64ea108c78d36ca4eafa7634e0e7 /not | |
parent | dd40241cc5a8a981db453304f91c7c3e1cbfbe5a (diff) | |
download | roflnauts-0b3de32ee8b9d79d7b818a6742ab577ff47525e6.zip roflnauts-0b3de32ee8b9d79d7b818a6742ab577ff47525e6.tar.gz roflnauts-0b3de32ee8b9d79d7b818a6742ab577ff47525e6.tar.bz2 |
MusicPlayer now don't share sources
Diffstat (limited to 'not')
-rw-r--r-- | not/MusicPlayer.lua | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/not/MusicPlayer.lua b/not/MusicPlayer.lua index 84f5384..d2a89c3 100644 --- a/not/MusicPlayer.lua +++ b/not/MusicPlayer.lua @@ -4,14 +4,13 @@ require "not.Object" -- Simple music player object that plays and loops selected track. MusicPlayer = Object:extends() -MusicPlayer.TRACKS = {} - --- TODO: trackName should be passed without file extension. function MusicPlayer:new (trackName) + self.tracks = {} self:setTrack(trackName) end function MusicPlayer:delete () + self.tracks = nil self.source:stop() end @@ -19,14 +18,14 @@ function MusicPlayer:setTrack (trackName) if self.source then self.source:stop() end - if MusicPlayer.TRACKS[trackName] then - self.source = MusicPlayer.TRACKS[trackName] + if self.tracks[trackName] then + self.source = self.tracks[trackName] else local source = love.audio.newSource("assets/music/" .. trackName) source:setLooping(true) source:setVolume(.7) self.source = source - MusicPlayer.TRACKS[trackName] = source + self.tracks[trackName] = source end self.source:play() end |