Is there any way to keep the background music playing all the time..? I mean, that I have a project which restarts the layout whenever player misses the target and when player hits target, it goes to next layout.. I would like the music to play without interruptions between layouts and/or restarts..
Develop games in your browser. Powerful, performant & highly capable.
You can use a global variable (musicOn) for this. Just set an event on start of layout to check this variable. If it's 0, then start the music (and set musicOn to 1).
Copy the event to every layout (or put it on a global event sheet), and once you've started the music it will just keep playing. Each time you go between layouts or restart a layout, it will check to see if music is already playing, and take appropriate action.
Edit: Don't forget to reset musicOn to 0 when you finally turn the music off though!
Hope that helps :)
Ah, yes.. simple as always! Thank you!
Hmm.. well it wasn't so simple or I'm doing it wrong..
<img src="https://dl.dropboxusercontent.com/u/105313968/Capx.png" border="0" />
This still starts the song from the beginning when the layout restarts or a new layout starts..
I've made a simple example of what I was suggesting. You were on the right track, just needed a few minor changes :)
The red button switches between layouts, and the blue button stops the music. You'll notice that when you switch between layouts, the music continues to play without stopping then restarting (because of our variable check)! However turning off the music, sets the variable back to 0, so when you switch to another layout, the music will restart again!
Music was supplied by tulamide :) You can find more free music by tulamide here.
Hope that makes things a little clearer :)