summaryrefslogtreecommitdiffhomepage
path: root/not/Music.lua
blob: ee930f4f9d2baccecd482749da227ed6f6a383ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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