I just finished implementing the music into the game I am working on and got the music to loop correctly and loop without skipping. Now though after a world is completed and the game goes back to the map the music is supposed to stop but continues and plays over the other music that is supposed to be playing. We think it has to do with the timer we have set for the loops but we are not sure on solutions for it. I can post some code if anyone would like a look to help them. Thanks for helping in advance! [import]uid: 94237 topic_id: 19435 reply_id: 319435[/import]
Hi
You shouldn’t use a timer to loop the music, you should use something like this:
loop1=audio.loadSound(‘loop.mp3’)
musicLoop = audio.play(loop1,{channel=1,loops=-1})
You can especify the channel so no other audio or sound hits your music channel, and you send the loops=-1 to loop it forever…
If you ever want to pause the music then you can use the variable as you set it in my example it is:
audio.pause(musicLoop)
and then to resume:
audio.resume(musicLoop)
I hope that helps you out…
Regards [import]uid: 75034 topic_id: 19435 reply_id: 75018[/import]
what the timer was for is that we need the music to also be able to start from any level as well as continue to loop if already started. [import]uid: 94237 topic_id: 19435 reply_id: 75019[/import]
That’s why i told you the audio.pause and audio.resume… if you start the level: audio.resume, if you close the level and want another music or something, or you opened the menues, you can use audio.pause. Then when you are back to the level you use audio.resume and it gets back to what was playing…
No need for any timer. Timers consume a lot of resources you should avoid them when you can.
Thats my 2 cents.
[import]uid: 75034 topic_id: 19435 reply_id: 75021[/import]
I see what you are saying, but I’m not sure if that is the best choice in this situation. From any level in the world we need the music to be able to start from the map and continue to play through out the rest of the world until the end. [import]uid: 94237 topic_id: 19435 reply_id: 75022[/import]
Well, on main.lua, you start the loop, on world end you pause the loop, on back to map or new level you resume the loop., if you don’t need it to stop ever just put audio.play with the loop=-1 and that will play until you exit the game. (or if you play anything else on the same channel) [import]uid: 75034 topic_id: 19435 reply_id: 75023[/import]
thanks for your help we gave it a try and it has worked perfectly so far with no flaws! [import]uid: 94237 topic_id: 19435 reply_id: 75024[/import]
Your welcome [import]uid: 75034 topic_id: 19435 reply_id: 75027[/import]