Looping Different Music Tracks

AwesomePassword

  • Posts: 104
Help!

I'm making a game, and there are a few different songs. After one song is done playing, it should randomly choose the next one, and then another one, and so on, looping random tracks indefinitely. However, the game is switching scenes rather quickly, and since timers don't carry onto different scenes, I don't know how to make this work.

I cant use the "Loop sound", since it'll just loop one track continuously, and I can't combine the songs together, since I want the game to choose a song randomly after one of the songs ends.

Any ideas?
~Password
===
Games:
-Tetra Factory - 80%

Tuo

  • *
  • Posts: 2469
I'd personally use a number game attribute. When the music begins to play, start the number at the length of the song (seconds x 100 if you are going to use an "always" event for the next step) and then constantly decrease it down to zero. You can do the decreasing in either an "always" code or a time loop code (always = slightly more lag but more accurate; how I'd do it), which is then in a behavior that all the scenes have. Once the attribute reaches zero, use an RNG to determine the next song and reset the number attribute to the length of that song and restart the process.

Looking at the sound code options, you can also use the "get position" and "get length" codes and see when they are equal (which would mean the sound is done playing).
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)