summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--not/MusicPlayer.lua11
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