summaryrefslogtreecommitdiffhomepage
path: root/not
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-09-09 06:24:59 +0200
committerAki <nthirtyone@gmail.com>2017-09-09 06:24:59 +0200
commitb74e8f712a11cf57462c51873b1cf505d90623e3 (patch)
tree2e89c474a650dde51678dc4770aaa4abaa0e5bd6 /not
parentca8dbe135034f7a72b6b40f6dfd7b772bd51cc39 (diff)
downloadroflnauts-b74e8f712a11cf57462c51873b1cf505d90623e3.zip
roflnauts-b74e8f712a11cf57462c51873b1cf505d90623e3.tar.gz
roflnauts-b74e8f712a11cf57462c51873b1cf505d90623e3.tar.bz2
Shortcut to setTrack in MusicPlayer:play
Diffstat (limited to 'not')
-rw-r--r--not/MusicPlayer.lua15
-rw-r--r--not/World.lua6
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