summaryrefslogtreecommitdiffhomepage
path: root/not/Music.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2017-04-09 22:07:04 +0200
committerAki <nthirtyone@gmail.com>2017-04-09 22:07:04 +0200
commit0dd01913fe0eefc7ba4bc0797877f40fdedf9315 (patch)
tree8d270eb07f589d2487b3ce66d4865e5a4718042a /not/Music.lua
parent55b0cf1a22e4a7e41fe00aa693445d6c4bd0652d (diff)
parenta03c1125f10fbbad253a0efc4727072fcbd55345 (diff)
downloadroflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.zip
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.gz
roflnauts-0dd01913fe0eefc7ba4bc0797877f40fdedf9315.tar.bz2
Merge branch 'com'
Diffstat (limited to 'not/Music.lua')
-rw-r--r--not/Music.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/not/Music.lua b/not/Music.lua
new file mode 100644
index 0000000..ee930f4
--- /dev/null
+++ b/not/Music.lua
@@ -0,0 +1,25 @@
+--- `Music`
+-- Simple music player object that plays and loops selected track in single Scene.
+Music = {
+ source = --[[love.audio.newSource]]nil
+}
+
+Music.__index = Music
+
+function Music:new (trackName)
+ local o = setmetatable({}, self)
+ o:init(trackName)
+ return o
+end
+
+-- TODO: trackName should be passed without file extension.
+function Music:init (trackName)
+ self.source = love.audio.newSource("assets/music/" .. trackName)
+ self.source:setLooping(true)
+ self.source:setVolume(.7)
+ self.source:play()
+end
+
+function Music:delete ()
+ self.source:stop()
+end \ No newline at end of file