diff options
-rw-r--r-- | not/MusicPlayer.lua | 15 | ||||
-rw-r--r-- | not/World.lua | 6 |
2 files changed, 10 insertions, 11 deletions
diff --git a/not/MusicPlayer.lua b/not/MusicPlayer.lua index 4634ed9..17beda4 100644 --- a/not/MusicPlayer.lua +++ b/not/MusicPlayer.lua @@ -1,8 +1,5 @@ -require "not.Object" - ---- `MusicPlayer` --- Simple music player object that plays and loops selected track. -MusicPlayer = Object:extends() +--- Simple music player object that stores, playes and loops tracks.. +MusicPlayer = require "not.Object":extends() function MusicPlayer:new (trackName) self.tracks = {} @@ -13,8 +10,9 @@ function MusicPlayer:new (trackName) end function MusicPlayer:delete () - self.tracks = nil self:stop() + self.tracks = nil + self.source = nil end function MusicPlayer:setTrack (trackName) @@ -40,7 +38,10 @@ function MusicPlayer:getCurrentTrack () end end -function MusicPlayer:play () +function MusicPlayer:play (trackName) + if trackName then + self:setTrack(trackName) + end self.source:play() end diff --git a/not/World.lua b/not/World.lua index c086bd5..ae00b48 100644 --- a/not/World.lua +++ b/not/World.lua @@ -1,5 +1,4 @@ ---- `World` --- Used to manage physical world and everything inside it: clouds, platforms, nauts, background etc. +--- Used to manage physical world and everything inside it: clouds, platforms, nauts, background etc. -- TODO: Possibly move common parts of `World` and `Menu` to abstract class `Scene`. World = require "not.Scene":extends() @@ -40,8 +39,7 @@ function World:new (map, nauts) self.camera = Camera(self) - musicPlayer:setTrack(self.map.theme) - musicPlayer:play() + musicPlayer:play(self.map.theme) end -- The end of the world |