Tip - How to have multiple music tracks that loop between scenes without starting and stopping again
Just posted an entry in the cookbook: http://cookbook.gamesalad.com/question/50437285a5d0963792000500
This is a very simple method to have different music tracks on different scenes and for them all to keep looping with no stops and starts.
You can also set up a jukebox where the player chooses from a selection of tracks. And they will all keep looping as you change between scenes until a new track is chosen.
First import your awesome music tracks which loop cleanly.
Then make a global integer: game.musicTrack and set it to 1
In one of the first actors in each scene (an actor at the bottom of the layers tab) place the following rule:
When game.musicTrack = 1
Play Music: YourFunkySong (make sure loop is checked)
Also include a timer here. After 2 seconds change game.musicTrack to 0.
otherwise
When game.musicTrack = 2
Play Music: VanillaIceMegaMix (make sure loop is checked)
Also include a timer here. After 2 seconds change game.musicTrack to 0.
etc
Create your buttons so that the player can choose different tracks. Let's say this example button changes the music to track 2. Add the following rule:
When touch is pressed
Change game.MusicTrack to 2
Now, here's the part that makes sure your track will keep looping even if you change scene. In one of the last actors on each scene (an actor at the top of the layers tab) include the following change attribute:
Change game.musicTrack to 0
Edit: And the timer mentioned above is why it works too. Basically after game.musicTrack is changed to 1 or 2 or whatever - somewhere you have to change it back to 0.
Now you can change scenes as much as you like and have multiple songs to choose from and your music will keep looping.
This is a very simple method to have different music tracks on different scenes and for them all to keep looping with no stops and starts.
You can also set up a jukebox where the player chooses from a selection of tracks. And they will all keep looping as you change between scenes until a new track is chosen.
First import your awesome music tracks which loop cleanly.
Then make a global integer: game.musicTrack and set it to 1
In one of the first actors in each scene (an actor at the bottom of the layers tab) place the following rule:
When game.musicTrack = 1
Play Music: YourFunkySong (make sure loop is checked)
Also include a timer here. After 2 seconds change game.musicTrack to 0.
otherwise
When game.musicTrack = 2
Play Music: VanillaIceMegaMix (make sure loop is checked)
Also include a timer here. After 2 seconds change game.musicTrack to 0.
etc
Create your buttons so that the player can choose different tracks. Let's say this example button changes the music to track 2. Add the following rule:
When touch is pressed
Change game.MusicTrack to 2
Now, here's the part that makes sure your track will keep looping even if you change scene. In one of the last actors on each scene (an actor at the top of the layers tab) include the following change attribute:
Change game.musicTrack to 0
Edit: And the timer mentioned above is why it works too. Basically after game.musicTrack is changed to 1 or 2 or whatever - somewhere you have to change it back to 0.
Now you can change scenes as much as you like and have multiple songs to choose from and your music will keep looping.
Comments
so simple now … to let the user select the music
… or have the music change from scene to scene
I say simple … and it is … but takes a genius to make things simple!
Thanx … big bunches of Thanx! … @HoneyTribeStudios