Log In  

Hello there,

I am playing the music from a function called intro.
This function is run in the update loop.
When the game state is intro then intro is showed and this is the moment I'd like to hear some music.

Problem is that the intro function is called every time the update loop restarts and therefore the music restarts everytime producing a choppy noise.

How can I solve this issue?

My code is available here:

Thanks for your time and help :)

P#38875 2017-03-30 07:38 ( Edited 2017-03-31 12:04)

something like that?

function togglemusic(n)
if (music_playing) then
music(-1) music_playing=false
music(n) music_playing=true

also I think there are peeks and pokes for the music whereabouts but I never looked into that.

edit: oups, sorry, not what you asked for.
this should do:

function startmusic(n)
if (not music_playing) then
music(n) music_playing=true

function stopmusic()
music(-1) music_playing=false

call startmusic() in intro()

P#38878 2017-03-30 09:58 ( Edited 2017-03-30 14:05)

Sadly it is not working :(

If I use the 2nd function you pasted and then I call startmuc in intro the game starts playing even if I'm still in intro (and I get no music).

P#38908 2017-03-31 05:13 ( Edited 2017-03-31 09:13)

there must be something else going on, these function shouldn't interfere with your game logic at all.

P#38912 2017-03-31 07:32 ( Edited 2017-03-31 11:32)

You're 100% right, I was using the wrong music code and it started playing - rightfully - my game's sfx :)

Really thanks :)

P#38915 2017-03-31 08:04 ( Edited 2017-03-31 12:04)

Did the bot hunt down the words "music"? Cause if so that's pretty malicious

P#106049 2022-01-31 17:13

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-02-21 10:32:46 | 0.006s | Q:15