summaryrefslogtreecommitdiffhomepage
path: root/music.lua
diff options
context:
space:
mode:
authorAki <nthirtyone@gmail.com>2016-08-05 16:30:51 +0200
committerAki <nthirtyone@gmail.com>2016-08-05 16:30:51 +0200
commitbf5f449516673d63e03b7a8859f419a9667ac295 (patch)
tree16ecc8282cbeab6f6189fedd2001c416b5509f67 /music.lua
parent17f4ae2f06e041edb3ecb30035c713a77c64fb46 (diff)
downloadroflnauts-bf5f449516673d63e03b7a8859f419a9667ac295.zip
roflnauts-bf5f449516673d63e03b7a8859f419a9667ac295.tar.gz
roflnauts-bf5f449516673d63e03b7a8859f419a9667ac295.tar.bz2
Main menu music
Diffstat (limited to 'music.lua')
-rw-r--r--music.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/music.lua b/music.lua
new file mode 100644
index 0000000..1ac26bb
--- /dev/null
+++ b/music.lua
@@ -0,0 +1,27 @@
+-- `Music`
+-- Simple music player object that plays and loops selected track in single Scene.
+
+-- WHOLE CODE HAS FLAG OF "need a cleanup"
+
+-- Metatable of `Music`
+-- nils initialized in constructor
+Music = {
+ track = nil,
+ source = nil
+}
+function Music:new(track)
+ -- Meta
+ local o = {}
+ setmetatable(o, self)
+ self.__index = self
+ -- Init
+ o.track = track
+ o.source = love.audio.newSource("assets/music/" .. o.track)
+ o.source:setLooping(true)
+ o.source:setVolume(.7)
+ o.source:play()
+ return o
+end
+function Music:delete()
+ self.source:stop()
+end \ No newline at end of file