How do you switch music when you go to the next level?
I am trying to switch boss music at level 10. But I do not know how to do that yet. Can someone help. :(
I am trying to switch boss music at level 10. But I do not know how to do that yet. Can someone help. :(
Game = class
constructor = function()
level = 1
music = audio.playMusic( level + "mp3" )
end
nextLevel = function()
level += 1
music.stop()
music = adio.playMusic( level + "mp3" )
end
end
thanks man. you have helped me once again. :)
the only thing is. what is the mp3 mean?
You place the music files in the project. You name them the same as the level they are to be played on. 1mp3 2mp3 3mp3
For one project, I created a simple music library that can loop and play music:
game_music = object
enabled = true
handle = 0
name = ""
loop = function(name)
if not enabled then return end
if this.name == name then
return
end
stop()
playing = true
handle = audio.playMusic(name, 1, loop)
handle.setPosition(0)
this.name = name
end
pause = function()
if handle then
handle.stop()
end
end
stop = function()
pause()
handle = 0
name = ""
end
update = function()
if handle then
handle.play()
if not enabled then
stop()
end
end
end
end
thanks, what do I do in the "name" ones. I do not get it.